android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / view / unmodpg.cxx
blobafd454a5f183c6d17ea9b99d4d0736676495dc61
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/svdlayer.hxx>
21 #include <sfx2/dispatch.hxx>
22 #include <sfx2/viewfrm.hxx>
23 #include <svx/svdviter.hxx>
24 #include <svx/svdview.hxx>
25 #include <tools/debug.hxx>
27 #include <strings.hrc>
28 #include <strings.hxx>
29 #include <glob.hxx>
30 #include <app.hrc>
32 #include <unmodpg.hxx>
33 #include <sdpage.hxx>
34 #include <sdresid.hxx>
35 #include <unokywds.hxx>
36 #include <drawdoc.hxx>
37 #include <utility>
40 ModifyPageUndoAction::ModifyPageUndoAction(
41 SdDrawDocument* pTheDoc,
42 SdPage* pThePage,
43 const OUString& aTheNewName,
44 AutoLayout eTheNewAutoLayout,
45 bool bTheNewBckgrndVisible,
46 bool bTheNewBckgrndObjsVisible)
47 : SdUndoAction(pTheDoc)
49 DBG_ASSERT(pThePage, "Undo without a page???");
51 mpPage = pThePage;
52 maNewName = aTheNewName;
53 meNewAutoLayout = eTheNewAutoLayout;
54 mbNewBckgrndVisible = bTheNewBckgrndVisible;
55 mbNewBckgrndObjsVisible = bTheNewBckgrndObjsVisible;
57 meOldAutoLayout = mpPage->GetAutoLayout();
59 if (!mpPage->IsMasterPage())
61 maOldName = mpPage->GetName();
62 SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
63 SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background);
64 SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects);
65 SdrLayerIDSet aVisibleLayers = mpPage->TRG_GetMasterPageVisibleLayers();
67 mbOldBckgrndVisible = aVisibleLayers.IsSet(aBckgrnd);
68 mbOldBckgrndObjsVisible = aVisibleLayers.IsSet(aBckgrndObj);
70 else
72 mbOldBckgrndVisible = false;
73 mbOldBckgrndObjsVisible = false;
76 if (pTheDoc && pTheDoc->GetDocumentType() == DocumentType::Draw)
77 SetComment( SdResId(STR_UNDO_MODIFY_PAGE_DRAW) );
78 else
79 SetComment( SdResId(STR_UNDO_MODIFY_PAGE) );
82 void ModifyPageUndoAction::Undo()
84 // invalidate Selection, there could be objects deleted in this UNDO
85 // which are no longer allowed to be selected then.
86 SdrViewIter aIter(mpPage);
87 SdrView* pView = aIter.FirstView();
89 while(pView)
91 if(pView->AreObjectsMarked())
92 pView->UnmarkAll();
93 pView = aIter.NextView();
96 mpPage->SetAutoLayout( meOldAutoLayout );
98 if (!mpPage->IsMasterPage())
100 if (mpPage->GetName() != maOldName)
102 mpPage->SetName(maOldName);
104 if (mpPage->GetPageKind() == PageKind::Standard)
106 SdPage* pNotesPage = static_cast<SdPage*>(mpDoc->GetPage(mpPage->GetPageNum() + 1));
107 pNotesPage->SetName(maOldName);
111 SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
112 SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background);
113 SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects);
114 SdrLayerIDSet aVisibleLayers;
115 aVisibleLayers.Set(aBckgrnd, mbOldBckgrndVisible);
116 aVisibleLayers.Set(aBckgrndObj, mbOldBckgrndObjsVisible);
117 mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
120 // Redisplay
121 SfxViewFrame* pCurrent = SfxViewFrame::Current();
122 if( pCurrent )
124 pCurrent->GetDispatcher()->Execute(
125 SID_SWITCHPAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
129 void ModifyPageUndoAction::Redo()
131 // invalidate Selection, there could be objects deleted in this UNDO
132 // which are no longer allowed to be selected then.
133 SdrViewIter aIter(mpPage);
134 SdrView* pView = aIter.FirstView();
136 while(pView)
138 if(pView->AreObjectsMarked())
139 pView->UnmarkAll();
140 pView = aIter.NextView();
143 mpPage->meAutoLayout = meNewAutoLayout;
145 if (!mpPage->IsMasterPage())
147 if (mpPage->GetName() != maNewName)
149 mpPage->SetName(maNewName);
151 if (mpPage->GetPageKind() == PageKind::Standard)
153 SdPage* pNotesPage = static_cast<SdPage*>(mpDoc->GetPage(mpPage->GetPageNum() + 1));
154 pNotesPage->SetName(maNewName);
158 SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
159 SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background);
160 SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects);
161 SdrLayerIDSet aVisibleLayers;
162 aVisibleLayers.Set(aBckgrnd, mbNewBckgrndVisible);
163 aVisibleLayers.Set(aBckgrndObj, mbNewBckgrndObjsVisible);
164 mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
167 // Redisplay
168 SfxViewFrame* pCurrent = SfxViewFrame::Current();
169 if( pCurrent )
171 pCurrent->GetDispatcher()->Execute(
172 SID_SWITCHPAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
176 ModifyPageUndoAction::~ModifyPageUndoAction()
180 RenameLayoutTemplateUndoAction::RenameLayoutTemplateUndoAction(
181 SdDrawDocument* pDocument,
182 OUString aOldLayoutName,
183 OUString aNewLayoutName)
184 : SdUndoAction(pDocument)
185 , maOldName(std::move(aOldLayoutName))
186 , maNewName(std::move(aNewLayoutName))
187 , maComment(SdResId(STR_TITLE_RENAMESLIDE))
189 sal_Int32 nPos = maOldName.indexOf(SD_LT_SEPARATOR);
190 if (nPos != -1)
191 maOldName = maOldName.copy(0, nPos);
194 void RenameLayoutTemplateUndoAction::Undo()
196 OUString aLayoutName(maNewName + SD_LT_SEPARATOR + STR_LAYOUT_OUTLINE);
197 mpDoc->RenameLayoutTemplate( aLayoutName, maOldName );
200 void RenameLayoutTemplateUndoAction::Redo()
202 OUString aLayoutName(maOldName + SD_LT_SEPARATOR + STR_LAYOUT_OUTLINE);
203 mpDoc->RenameLayoutTemplate( aLayoutName, maNewName );
206 OUString RenameLayoutTemplateUndoAction::GetComment() const
208 return maComment;
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */