1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/viewfrm.hxx>
22 #include <sfx2/dispatch.hxx>
23 #include <svx/fmshell.hxx>
24 #include <svx/svxdlg.hxx>
25 #include <osl/diagnose.h>
29 #include <drawdoc.hxx>
30 #include <DrawDocShell.hxx>
31 #include <unokywds.hxx>
33 #include <DrawViewShell.hxx>
34 #include <drawview.hxx>
35 #include <unmodpg.hxx>
36 #include <ViewShellBase.hxx>
37 #include <FormShellManager.hxx>
38 #include <LayerTabBar.hxx>
39 #include <SlideSorterViewShell.hxx>
40 #include <SlideSorter.hxx>
41 #include <controller/SlideSorterController.hxx>
45 bool DrawViewShell::RenameSlide( sal_uInt16 nPageId
, const OUString
& rName
)
48 if( GetDoc()->GetPageByName( rName
, bOutDummy
) != SDRPAGE_NOTFOUND
)
51 SdPage
* pPageToRename
= nullptr;
52 PageKind ePageKind
= GetPageKind();
54 if( GetEditMode() == EditMode::Page
)
56 pPageToRename
= GetDoc()->GetSdPage( maTabControl
->GetPagePos(nPageId
), ePageKind
);
59 SdPage
* pUndoPage
= pPageToRename
;
60 SdrLayerAdmin
& rLayerAdmin
= GetDoc()->GetLayerAdmin();
61 SdrLayerID nBackground
= rLayerAdmin
.GetLayerID(sUNO_LayerName_background
);
62 SdrLayerID nBgObj
= rLayerAdmin
.GetLayerID(sUNO_LayerName_background_objects
);
63 SdrLayerIDSet aVisibleLayers
= mpActualPage
->TRG_GetMasterPageVisibleLayers();
65 SfxUndoManager
* pManager
= GetDoc()->GetDocSh()->GetUndoManager();
66 pManager
->AddUndoAction(
67 std::make_unique
<ModifyPageUndoAction
>(
68 GetDoc(), pUndoPage
, rName
, pUndoPage
->GetAutoLayout(),
69 aVisibleLayers
.IsSet( nBackground
),
70 aVisibleLayers
.IsSet( nBgObj
)));
73 pPageToRename
->SetName( rName
);
75 if( ePageKind
== PageKind::Standard
)
77 // also rename notes-page
78 SdPage
* pNotesPage
= GetDoc()->GetSdPage( maTabControl
->GetPagePos(nPageId
), PageKind::Notes
);
79 pNotesPage
->SetName( rName
);
84 // rename MasterPage -> rename LayoutTemplate
85 pPageToRename
= GetDoc()->GetMasterSdPage( maTabControl
->GetPagePos(nPageId
), ePageKind
);
86 GetDoc()->RenameLayoutTemplate( pPageToRename
->GetLayoutName(), rName
);
89 bool bSuccess
= (rName
== pPageToRename
->GetName());
93 // user edited page names may be changed by the page so update control
94 maTabControl
->SetPageText( nPageId
, rName
);
96 // set document to modified state
97 GetDoc()->SetChanged();
99 // inform navigator about change
102 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
103 rBindings
.Invalidate(SID_NAVIGATOR_STATE
, true);
106 // Tell the slide sorter about the name change (necessary for
108 slidesorter::SlideSorterViewShell
* pSlideSorterViewShell
109 = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
110 if (pSlideSorterViewShell
!= nullptr)
112 pSlideSorterViewShell
->GetSlideSorter().GetController().PageNameHasChanged(
113 maTabControl
->GetPagePos(nPageId
), rName
);
120 IMPL_LINK( DrawViewShell
, RenameSlideHdl
, AbstractSvxNameDialog
&, rDialog
, bool )
123 rDialog
.GetName( aNewName
);
125 SdPage
* pCurrentPage
= GetDoc()->GetSdPage( maTabControl
->GetCurPagePos(), GetPageKind() );
127 return pCurrentPage
&& ( aNewName
== pCurrentPage
->GetName() || GetDocSh()->IsNewPageNameValid( aNewName
) );
130 void DrawViewShell::ModifyLayer (
132 const OUString
& rLayerName
,
133 const OUString
& rLayerTitle
,
134 const OUString
& rLayerDesc
,
139 if(!GetLayerTabControl()) // #i87182#
141 OSL_ENSURE(false, "No LayerTabBar (!)");
148 const sal_uInt16 nPageCount
= GetLayerTabControl()->GetPageCount();
149 sal_uInt16 nCurPage
= 0;
151 for( nPos
= 0; nPos
< nPageCount
; nPos
++ )
153 sal_uInt16 nId
= GetLayerTabControl()->GetPageId( nPos
);
154 if (GetLayerTabControl()->GetLayerName(nId
) == pLayer
->GetName())
161 pLayer
->SetName( rLayerName
);
162 pLayer
->SetTitle( rLayerTitle
);
163 pLayer
->SetDescription( rLayerDesc
);
164 mpDrawView
->SetLayerVisible( rLayerName
, bIsVisible
);
165 mpDrawView
->SetLayerLocked( rLayerName
, bIsLocked
);
166 mpDrawView
->SetLayerPrintable(rLayerName
, bIsPrintable
);
168 GetDoc()->SetChanged();
170 GetLayerTabControl()->SetPageText(nCurPage
, rLayerName
);
172 // Set page bits for modified tab name display
174 TabBarPageBits nBits
= TabBarPageBits::NONE
;
178 nBits
= TabBarPageBits::Blue
;
182 nBits
|= TabBarPageBits::Italic
;
186 nBits
|= TabBarPageBits::Underline
;
191 GetLayerTabControl()->SetPageBits(nCurPage
, nBits
);
193 GetViewFrame()->GetDispatcher()->Execute(
195 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
197 // Call Invalidate at the form shell.
198 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
199 if (pFormShell
!= nullptr)
200 pFormShell
->Invalidate();
203 } // end of namespace sd
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */