/src/libreoffice/sd/source/ui/view/drviewsb.cxx
Line | Count | Source (jump to first uncovered line) |
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/viewfrm.hxx> |
22 | | #include <sfx2/dispatch.hxx> |
23 | | #include <svx/fmshell.hxx> |
24 | | #include <svx/svxdlg.hxx> |
25 | | #include <osl/diagnose.h> |
26 | | |
27 | | #include <app.hrc> |
28 | | |
29 | | #include <drawdoc.hxx> |
30 | | #include <DrawDocShell.hxx> |
31 | | #include <unokywds.hxx> |
32 | | #include <sdpage.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> |
42 | | |
43 | | namespace sd { |
44 | | |
45 | | bool DrawViewShell::RenameSlide( sal_uInt16 nPageId, const OUString & rName ) |
46 | 0 | { |
47 | 0 | bool bOutDummy; |
48 | 0 | if( GetDoc()->GetPageByName( rName, bOutDummy ) != SDRPAGE_NOTFOUND ) |
49 | 0 | return false; |
50 | | |
51 | 0 | SdPage* pPageToRename = nullptr; |
52 | 0 | PageKind ePageKind = GetPageKind(); |
53 | |
|
54 | 0 | if( GetEditMode() == EditMode::Page ) |
55 | 0 | { |
56 | 0 | pPageToRename = GetDoc()->GetSdPage( maTabControl->GetPagePos(nPageId), ePageKind ); |
57 | | |
58 | | // Undo |
59 | 0 | SdPage* pUndoPage = pPageToRename; |
60 | 0 | SdrLayerAdmin & rLayerAdmin = GetDoc()->GetLayerAdmin(); |
61 | 0 | SdrLayerID nBackground = rLayerAdmin.GetLayerID(sUNO_LayerName_background); |
62 | 0 | SdrLayerID nBgObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); |
63 | 0 | SdrLayerIDSet aVisibleLayers = mpActualPage->TRG_GetMasterPageVisibleLayers(); |
64 | |
|
65 | 0 | SfxUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager(); |
66 | 0 | pManager->AddUndoAction( |
67 | 0 | std::make_unique<ModifyPageUndoAction>( |
68 | 0 | *GetDoc(), pUndoPage, rName, pUndoPage->GetAutoLayout(), |
69 | 0 | aVisibleLayers.IsSet( nBackground ), |
70 | 0 | aVisibleLayers.IsSet( nBgObj ))); |
71 | | |
72 | | // rename |
73 | 0 | pPageToRename->SetName( rName ); |
74 | |
|
75 | 0 | if( ePageKind == PageKind::Standard ) |
76 | 0 | { |
77 | | // also rename notes-page |
78 | 0 | SdPage* pNotesPage = GetDoc()->GetSdPage( maTabControl->GetPagePos(nPageId), PageKind::Notes ); |
79 | 0 | pNotesPage->SetName( rName ); |
80 | 0 | } |
81 | 0 | } |
82 | 0 | else |
83 | 0 | { |
84 | | // rename MasterPage -> rename LayoutTemplate |
85 | 0 | pPageToRename = GetDoc()->GetMasterSdPage( maTabControl->GetPagePos(nPageId), ePageKind ); |
86 | 0 | OUString aOldPageLayoutName = pPageToRename->GetLayoutName(); |
87 | 0 | GetDoc()->RenameLayoutTemplate(aOldPageLayoutName, rName); |
88 | 0 | } |
89 | |
|
90 | 0 | bool bSuccess = (rName == pPageToRename->GetName()); |
91 | |
|
92 | 0 | if( bSuccess ) |
93 | 0 | { |
94 | | // user edited page names may be changed by the page so update control |
95 | 0 | maTabControl->SetPageText( nPageId, rName ); |
96 | | |
97 | | // set document to modified state |
98 | 0 | GetDoc()->SetChanged(); |
99 | | |
100 | | // inform navigator about change |
101 | 0 | if (GetViewFrame()) |
102 | 0 | { |
103 | 0 | SfxBindings& rBindings = GetViewFrame()->GetBindings(); |
104 | 0 | rBindings.Invalidate(SID_NAVIGATOR_STATE, true); |
105 | 0 | } |
106 | | |
107 | | // Tell the slide sorter about the name change (necessary for |
108 | | // accessibility.) |
109 | 0 | slidesorter::SlideSorterViewShell* pSlideSorterViewShell |
110 | 0 | = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase()); |
111 | 0 | if (pSlideSorterViewShell != nullptr) |
112 | 0 | { |
113 | 0 | pSlideSorterViewShell->GetSlideSorter().GetController().PageNameHasChanged( |
114 | 0 | maTabControl->GetPagePos(nPageId), rName); |
115 | 0 | } |
116 | 0 | } |
117 | |
|
118 | 0 | return bSuccess; |
119 | 0 | } |
120 | | |
121 | | IMPL_LINK( DrawViewShell, RenameSlideHdl, AbstractSvxNameDialog&, rDialog, bool ) |
122 | 0 | { |
123 | 0 | OUString aNewName = rDialog.GetName(); |
124 | |
|
125 | 0 | SdPage* pCurrentPage = GetDoc()->GetSdPage( maTabControl->GetCurPagePos(), GetPageKind() ); |
126 | |
|
127 | 0 | return pCurrentPage && ( aNewName == pCurrentPage->GetName() || GetDocSh()->IsNewPageNameValid( aNewName ) ); |
128 | 0 | } |
129 | | |
130 | | void DrawViewShell::ModifyLayer ( |
131 | | SdrLayer* pLayer, |
132 | | const OUString& rLayerName, |
133 | | const OUString& rLayerTitle, |
134 | | const OUString& rLayerDesc, |
135 | | bool bIsVisible, |
136 | | bool bIsLocked, |
137 | | bool bIsPrintable) |
138 | 0 | { |
139 | 0 | if(!GetLayerTabControl()) // #i87182# |
140 | 0 | { |
141 | 0 | OSL_ENSURE(false, "No LayerTabBar (!)"); |
142 | 0 | return; |
143 | 0 | } |
144 | | |
145 | 0 | if( !pLayer ) |
146 | 0 | return; |
147 | | |
148 | 0 | const sal_uInt16 nPageCount = GetLayerTabControl()->GetPageCount(); |
149 | 0 | sal_uInt16 nCurPage = 0; |
150 | 0 | sal_uInt16 nPos; |
151 | 0 | for( nPos = 0; nPos < nPageCount; nPos++ ) |
152 | 0 | { |
153 | 0 | sal_uInt16 nId = GetLayerTabControl()->GetPageId( nPos ); |
154 | 0 | if (GetLayerTabControl()->GetLayerName(nId) == pLayer->GetName()) |
155 | 0 | { |
156 | 0 | nCurPage = nId; |
157 | 0 | break; |
158 | 0 | } |
159 | 0 | } |
160 | |
|
161 | 0 | pLayer->SetName( rLayerName ); |
162 | 0 | pLayer->SetTitle( rLayerTitle ); |
163 | 0 | pLayer->SetDescription( rLayerDesc ); |
164 | 0 | mpDrawView->SetLayerVisible( rLayerName, bIsVisible ); |
165 | 0 | mpDrawView->SetLayerLocked( rLayerName, bIsLocked); |
166 | 0 | mpDrawView->SetLayerPrintable(rLayerName, bIsPrintable); |
167 | |
|
168 | 0 | GetDoc()->SetChanged(); |
169 | |
|
170 | 0 | GetLayerTabControl()->SetPageText(nCurPage, rLayerName); |
171 | | |
172 | | // Set page bits for modified tab name display |
173 | |
|
174 | 0 | TabBarPageBits nBits = TabBarPageBits::NONE; |
175 | |
|
176 | 0 | if (!bIsVisible) |
177 | 0 | { |
178 | 0 | nBits = TabBarPageBits::Blue; |
179 | 0 | } |
180 | 0 | if (bIsLocked) |
181 | 0 | { |
182 | 0 | nBits |= TabBarPageBits::Italic; |
183 | 0 | } |
184 | 0 | if (!bIsPrintable) |
185 | 0 | { |
186 | 0 | nBits |= TabBarPageBits::Underline; |
187 | 0 | } |
188 | | |
189 | | // Save the bits |
190 | |
|
191 | 0 | GetLayerTabControl()->SetPageBits(nCurPage, nBits); |
192 | |
|
193 | 0 | GetViewFrame()->GetDispatcher()->Execute( |
194 | 0 | SID_SWITCHLAYER, |
195 | 0 | SfxCallMode::ASYNCHRON | SfxCallMode::RECORD); |
196 | | |
197 | | // Call Invalidate at the form shell. |
198 | 0 | FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell(); |
199 | 0 | if (pFormShell != nullptr) |
200 | 0 | pFormShell->Invalidate(); |
201 | 0 | } |
202 | | |
203 | | } // end of namespace sd |
204 | | |
205 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |