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 )
122 OUString aNewName
= rDialog
.GetName();
124 SdPage
* pCurrentPage
= GetDoc()->GetSdPage( maTabControl
->GetCurPagePos(), GetPageKind() );
126 return pCurrentPage
&& ( aNewName
== pCurrentPage
->GetName() || GetDocSh()->IsNewPageNameValid( aNewName
) );
129 void DrawViewShell::ModifyLayer (
131 const OUString
& rLayerName
,
132 const OUString
& rLayerTitle
,
133 const OUString
& rLayerDesc
,
138 if(!GetLayerTabControl()) // #i87182#
140 OSL_ENSURE(false, "No LayerTabBar (!)");
147 const sal_uInt16 nPageCount
= GetLayerTabControl()->GetPageCount();
148 sal_uInt16 nCurPage
= 0;
150 for( nPos
= 0; nPos
< nPageCount
; nPos
++ )
152 sal_uInt16 nId
= GetLayerTabControl()->GetPageId( nPos
);
153 if (GetLayerTabControl()->GetLayerName(nId
) == pLayer
->GetName())
160 pLayer
->SetName( rLayerName
);
161 pLayer
->SetTitle( rLayerTitle
);
162 pLayer
->SetDescription( rLayerDesc
);
163 mpDrawView
->SetLayerVisible( rLayerName
, bIsVisible
);
164 mpDrawView
->SetLayerLocked( rLayerName
, bIsLocked
);
165 mpDrawView
->SetLayerPrintable(rLayerName
, bIsPrintable
);
167 GetDoc()->SetChanged();
169 GetLayerTabControl()->SetPageText(nCurPage
, rLayerName
);
171 // Set page bits for modified tab name display
173 TabBarPageBits nBits
= TabBarPageBits::NONE
;
177 nBits
= TabBarPageBits::Blue
;
181 nBits
|= TabBarPageBits::Italic
;
185 nBits
|= TabBarPageBits::Underline
;
190 GetLayerTabControl()->SetPageBits(nCurPage
, nBits
);
192 GetViewFrame()->GetDispatcher()->Execute(
194 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
196 // Call Invalidate at the form shell.
197 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
198 if (pFormShell
!= nullptr)
199 pFormShell
->Invalidate();
202 } // end of namespace sd
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */