LibreOffice Module sd (master) 1
unmodpg.cxx
Go to the documentation of this file.
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#include <svx/svdviter.hxx>
24#include <svx/svdview.hxx>
25#include <tools/debug.hxx>
26
27#include <strings.hrc>
28#include <strings.hxx>
29#include <glob.hxx>
30#include <app.hrc>
31
32#include <unmodpg.hxx>
33#include <sdpage.hxx>
34#include <sdresid.hxx>
35#include <unokywds.hxx>
36#include <drawdoc.hxx>
37#include <utility>
38
39#include <ViewShell.hxx>
40#include <ViewShellBase.hxx>
41#include <DrawDocShell.hxx>
42#include <SlideSorter.hxx>
45
47 SdDrawDocument* pTheDoc,
48 SdPage* pThePage,
49 const OUString& aTheNewName,
50 AutoLayout eTheNewAutoLayout,
51 bool bTheNewBckgrndVisible,
52 bool bTheNewBckgrndObjsVisible)
53: SdUndoAction(pTheDoc)
54{
55 DBG_ASSERT(pThePage, "Undo without a page???");
56
57 mpPage = pThePage;
58 maNewName = aTheNewName;
59 meNewAutoLayout = eTheNewAutoLayout;
60 mbNewBckgrndVisible = bTheNewBckgrndVisible;
61 mbNewBckgrndObjsVisible = bTheNewBckgrndObjsVisible;
62
64
65 if (!mpPage->IsMasterPage())
66 {
68 SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
69 SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background);
72
73 mbOldBckgrndVisible = aVisibleLayers.IsSet(aBckgrnd);
74 mbOldBckgrndObjsVisible = aVisibleLayers.IsSet(aBckgrndObj);
75 }
76 else
77 {
78 mbOldBckgrndVisible = false;
80 }
81
82 if (pTheDoc && pTheDoc->GetDocumentType() == DocumentType::Draw)
83 SetComment( SdResId(STR_UNDO_MODIFY_PAGE_DRAW) );
84 else
85 SetComment( SdResId(STR_UNDO_MODIFY_PAGE) );
86}
87
89{
90 // invalidate Selection, there could be objects deleted in this UNDO
91 // which are no longer allowed to be selected then.
93 [] (SdrView* pView)
94 {
95 if(pView->AreObjectsMarked())
96 pView->UnmarkAll();
97 });
98
100
101 if (!mpPage->IsMasterPage())
102 {
103 if (mpPage->GetName() != maOldName)
104 {
106
108 {
109 SdPage* pNotesPage = static_cast<SdPage*>(mpDoc->GetPage(mpPage->GetPageNum() + 1));
110 pNotesPage->SetName(maOldName);
111 }
112 }
113
114 SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
115 SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background);
117 SdrLayerIDSet aVisibleLayers;
118 aVisibleLayers.Set(aBckgrnd, mbOldBckgrndVisible);
119 aVisibleLayers.Set(aBckgrndObj, mbOldBckgrndObjsVisible);
120 mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
121 }
122
123 // Redisplay
125 if( pCurrent )
126 {
127 pCurrent->GetDispatcher()->Execute(
128 SID_SWITCHPAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
129 }
130}
131
133{
134 // invalidate Selection, there could be objects deleted in this UNDO
135 // which are no longer allowed to be selected then.
137 [] (SdrView* pView)
138 {
139 if(pView->AreObjectsMarked())
140 pView->UnmarkAll();
141 });
142
144
145 if (!mpPage->IsMasterPage())
146 {
147 if (mpPage->GetName() != maNewName)
148 {
150
152 {
153 SdPage* pNotesPage = static_cast<SdPage*>(mpDoc->GetPage(mpPage->GetPageNum() + 1));
154 pNotesPage->SetName(maNewName);
155 }
156 }
157
158 SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
159 SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background);
161 SdrLayerIDSet aVisibleLayers;
162 aVisibleLayers.Set(aBckgrnd, mbNewBckgrndVisible);
163 aVisibleLayers.Set(aBckgrndObj, mbNewBckgrndObjsVisible);
164 mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
165 }
166
167 // Redisplay
169 if( pCurrent )
170 {
171 pCurrent->GetDispatcher()->Execute(
172 SID_SWITCHPAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
173 }
174}
175
177{
178}
179
182 const bool bOldStateValue)
183 : SdUndoAction(pDocument)
184 , meState(eState)
185 , mbOldStateValue(bOldStateValue)
186 , maComment(bOldStateValue ? SdResId(STR_UNDO_SHOW_SLIDE) : SdResId(STR_UNDO_HIDE_SLIDE))
187{
188}
189
191 SdDrawDocument* pDocument, const sd::slidesorter::model::SharedPageDescriptor& rpDescriptor,
192 const sd::slidesorter::model::PageDescriptor::State eState, const bool bOldStateValue)
193 : ChangeSlideExclusionStateUndoAction(pDocument, eState, bOldStateValue)
194{
195 mrpDescriptors.push_back(rpDescriptor);
196}
197
200{
201 mrpDescriptors.push_back(rpDescriptor);
202}
203
205{
206 sd::DrawDocShell* pDocShell = mpDoc ? mpDoc->GetDocSh() : nullptr;
207 sd::ViewShell* pViewShell = pDocShell ? pDocShell->GetViewShell() : nullptr;
208 if (pViewShell)
209 {
210 sd::slidesorter::SlideSorterViewShell* pSlideSorterViewShell
212 if (pSlideSorterViewShell)
213 {
215 pSlideSorterViewShell->GetSlideSorter().GetView().SetState(rpDescriptor, meState,
217 }
218 }
219}
220
222{
223 sd::DrawDocShell* pDocShell = mpDoc ? mpDoc->GetDocSh() : nullptr;
224 sd::ViewShell* pViewShell = pDocShell ? pDocShell->GetViewShell() : nullptr;
225 if (pViewShell)
226 {
227 sd::slidesorter::SlideSorterViewShell* pSlideSorterViewShell
229 if (pSlideSorterViewShell)
230 {
232 pSlideSorterViewShell->GetSlideSorter().GetView().SetState(rpDescriptor, meState,
234 }
235 }
236}
237
239{
240 return maComment;
241}
242
244 SdDrawDocument* pDocument,
245 OUString aOldLayoutName,
246 OUString aNewLayoutName)
247 : SdUndoAction(pDocument)
248 , maOldName(std::move(aOldLayoutName))
249 , maNewName(std::move(aNewLayoutName))
250 , maComment(SdResId(STR_TITLE_RENAMESLIDE))
251{
252 sal_Int32 nPos = maOldName.indexOf(SD_LT_SEPARATOR);
253 if (nPos != -1)
254 maOldName = maOldName.copy(0, nPos);
255}
256
258{
259 OUString aLayoutName(maNewName + SD_LT_SEPARATOR + STR_LAYOUT_OUTLINE);
260 mpDoc->RenameLayoutTemplate( aLayoutName, maOldName );
261}
262
264{
265 OUString aLayoutName(maOldName + SD_LT_SEPARATOR + STR_LAYOUT_OUTLINE);
266 mpDoc->RenameLayoutTemplate( aLayoutName, maNewName );
267}
268
270{
271 return maComment;
272}
273
274/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AutoLayout
void AddPageDescriptor(const sd::slidesorter::model::SharedPageDescriptor &rpDescriptor)
Definition: unmodpg.cxx:198
virtual OUString GetComment() const override
Definition: unmodpg.cxx:238
ChangeSlideExclusionStateUndoAction(SdDrawDocument *pDocument, const sd::slidesorter::model::PageDescriptor::State eState, const bool bOldStateValue)
Definition: unmodpg.cxx:180
virtual void Redo() override
Definition: unmodpg.cxx:221
std::vector< sd::slidesorter::model::SharedPageDescriptor > mrpDescriptors
Definition: unmodpg.hxx:79
sd::slidesorter::model::PageDescriptor::State meState
Definition: unmodpg.hxx:77
virtual void Undo() override
Definition: unmodpg.cxx:204
OUString maOldName
Definition: unmodpg.hxx:35
OUString maNewName
Definition: unmodpg.hxx:36
ModifyPageUndoAction(SdDrawDocument *pTheDoc, SdPage *pThePage, const OUString &aTheNewName, AutoLayout eTheNewAutoLayout, bool bTheNewBckgrndVisible, bool bTheNewBckgrndObjsVisible)
Definition: unmodpg.cxx:46
virtual void Redo() override
Definition: unmodpg.cxx:132
AutoLayout meOldAutoLayout
Definition: unmodpg.hxx:37
virtual ~ModifyPageUndoAction() override
Definition: unmodpg.cxx:176
bool mbNewBckgrndObjsVisible
Definition: unmodpg.hxx:42
bool mbOldBckgrndObjsVisible
Definition: unmodpg.hxx:41
virtual void Undo() override
Definition: unmodpg.cxx:88
AutoLayout meNewAutoLayout
Definition: unmodpg.hxx:38
RenameLayoutTemplateUndoAction(SdDrawDocument *pDocument, OUString aOldLayoutName, OUString aNewLayoutName)
Definition: unmodpg.cxx:243
virtual void Redo() override
Definition: unmodpg.cxx:263
virtual OUString GetComment() const override
Definition: unmodpg.cxx:269
virtual void Undo() override
Definition: unmodpg.cxx:257
SAL_DLLPRIVATE void RenameLayoutTemplate(const OUString &rOldLayoutName, const OUString &rNewName)
Definition: drawdoc4.cxx:1018
SAL_DLLPRIVATE::sd::DrawDocShell * GetDocSh() const
Definition: drawdoc.hxx:242
SAL_DLLPRIVATE DocumentType GetDocumentType() const
Definition: drawdoc.hxx:251
AutoLayout meAutoLayout
AutoLayout.
Definition: sdpage.hxx:106
PageKind GetPageKind() const
Definition: sdpage.hxx:205
void SetAutoLayout(AutoLayout eLayout, bool bInit=false, bool bCreate=false)
Definition: sdpage.cxx:1610
const OUString & GetName() const
Definition: sdpage.cxx:2505
void SetName(const OUString &rName)
Set the name of the page and broadcast a model change.
Definition: sdpage.cxx:2703
AutoLayout GetAutoLayout() const
Definition: sdpage.hxx:190
void SetComment(const OUString &rStr)
Definition: sdundo.hxx:32
SdDrawDocument * mpDoc
Definition: sdundo.hxx:39
SdrLayerID GetLayerID(const OUString &rName) const
void Set(SdrLayerID a)
bool IsSet(SdrLayerID a) const
bool AreObjectsMarked() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
const SdrLayerAdmin & GetLayerAdmin() const
sal_uInt16 GetPageNum() const
bool IsMasterPage() const
void TRG_SetMasterPageVisibleLayers(const SdrLayerIDSet &rNew)
const SdrLayerIDSet & TRG_GetMasterPageVisibleLayers() const
void UnmarkAll()
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxDispatcher * GetDispatcher()
sd::ViewShell * GetViewShell()
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
::sd::View * GetView() const
Definition: ViewShell.hxx:144
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
SD_DLLPUBLIC SlideSorter & GetSlideSorter() const
static SD_DLLPUBLIC SlideSorterViewShell * GetSlideSorter(ViewShellBase &rBase)
Return a slide sorter that is currently displayed in one of the panes that belong to the given ViewSh...
#define DBG_ASSERT(sCon, aError)
constexpr OUStringLiteral SD_LT_SEPARATOR
Definition: glob.hxx:49
sal_uInt16 nPos
void ForAllViews(const SdrPage *pPage, std::function< void(SdrView *)> f)
std::shared_ptr< PageDescriptor > SharedPageDescriptor
OUString maComment
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
constexpr OUStringLiteral STR_LAYOUT_OUTLINE
Definition: strings.hxx:16
constexpr OUStringLiteral sUNO_LayerName_background_objects
Definition: unokywds.hxx:30
constexpr OUStringLiteral sUNO_LayerName_background
Definition: unokywds.hxx:29