Line data Source code
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 <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
21 : #include <comphelper/processfactory.hxx>
22 : #include <svx/svdlayer.hxx>
23 : #include <svx/svxids.hrc>
24 : #include <sfx2/msgpool.hxx>
25 : #include <sfx2/viewfrm.hxx>
26 : #include <svx/hlnkitem.hxx>
27 : #include <editeng/eeitem.hxx>
28 : #include <editeng/flditem.hxx>
29 : #include <vcl/msgbox.hxx>
30 : #include <sfx2/request.hxx>
31 : #include <sfx2/dispatch.hxx>
32 : #include <svx/svdorect.hxx>
33 : #include <sfx2/docfile.hxx>
34 : #include <basic/sbstar.hxx>
35 : #include <basic/sberrors.hxx>
36 : #include <svx/fmshell.hxx>
37 : #include <svx/svxdlg.hxx>
38 : #include <svx/dialogs.hrc>
39 : #include <unotools/useroptions.hxx>
40 : #include <tools/diagnose_ex.h>
41 :
42 : #include "app.hrc"
43 : #include "strings.hrc"
44 : #include "res_bmp.hrc"
45 : #include "glob.hrc"
46 : #include "Outliner.hxx"
47 : #include "Window.hxx"
48 : #include "sdmod.hxx"
49 : #include "sdattr.hxx"
50 : #include "drawdoc.hxx"
51 : #include "DrawDocShell.hxx"
52 : #include "sdresid.hxx"
53 : #include "sdpage.hxx"
54 : #include "DrawViewShell.hxx"
55 : #include "drawview.hxx"
56 : #include "unmodpg.hxx"
57 : #include "undolayer.hxx"
58 : #include "ViewShellBase.hxx"
59 : #include "FormShellManager.hxx"
60 : #include "LayerTabBar.hxx"
61 : #include "sdabstdlg.hxx"
62 : #include "SlideSorterViewShell.hxx"
63 : #include "SlideSorter.hxx"
64 : #include "controller/SlideSorterController.hxx"
65 :
66 : namespace sd {
67 :
68 0 : bool DrawViewShell::RenameSlide( sal_uInt16 nPageId, const OUString & rName )
69 : {
70 : bool bOutDummy;
71 0 : if( GetDoc()->GetPageByName( rName, bOutDummy ) != SDRPAGE_NOTFOUND )
72 0 : return false;
73 :
74 0 : SdPage* pPageToRename = NULL;
75 0 : PageKind ePageKind = GetPageKind();
76 :
77 0 : if( GetEditMode() == EM_PAGE )
78 : {
79 0 : pPageToRename = GetDoc()->GetSdPage( nPageId - 1, ePageKind );
80 :
81 : // Undo
82 0 : SdPage* pUndoPage = pPageToRename;
83 0 : SdrLayerAdmin & rLayerAdmin = GetDoc()->GetLayerAdmin();
84 0 : sal_uInt8 nBackground = rLayerAdmin.GetLayerID( SD_RESSTR(STR_LAYER_BCKGRND), false );
85 0 : sal_uInt8 nBgObj = rLayerAdmin.GetLayerID( SD_RESSTR(STR_LAYER_BCKGRNDOBJ), false );
86 0 : SetOfByte aVisibleLayers = mpActualPage->TRG_GetMasterPageVisibleLayers();
87 :
88 0 : ::svl::IUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager();
89 : ModifyPageUndoAction* pAction = new ModifyPageUndoAction(
90 0 : GetDoc(), pUndoPage, rName, pUndoPage->GetAutoLayout(),
91 0 : aVisibleLayers.IsSet( nBackground ),
92 0 : aVisibleLayers.IsSet( nBgObj ));
93 0 : pManager->AddUndoAction( pAction );
94 :
95 : // rename
96 0 : pPageToRename->SetName( rName );
97 :
98 0 : if( ePageKind == PK_STANDARD )
99 : {
100 : // also rename notes-page
101 0 : SdPage* pNotesPage = GetDoc()->GetSdPage( nPageId - 1, PK_NOTES );
102 0 : pNotesPage->SetName( rName );
103 : }
104 : }
105 : else
106 : {
107 : // rename MasterPage -> rename LayoutTemplate
108 0 : pPageToRename = GetDoc()->GetMasterSdPage( nPageId - 1, ePageKind );
109 0 : GetDoc()->RenameLayoutTemplate( pPageToRename->GetLayoutName(), rName );
110 : }
111 :
112 0 : bool bSuccess = (rName == pPageToRename->GetName());
113 :
114 0 : if( bSuccess )
115 : {
116 : // user edited page names may be changed by the page so update control
117 0 : maTabControl.SetPageText( nPageId, rName );
118 :
119 : // set document to modified state
120 0 : GetDoc()->SetChanged( true );
121 :
122 : // inform navigator about change
123 0 : SfxBoolItem aItem( SID_NAVIGATOR_INIT, true );
124 : GetViewFrame()->GetDispatcher()->Execute(
125 0 : SID_NAVIGATOR_INIT, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, &aItem, 0L );
126 :
127 : // Tell the slide sorter about the name change (necessary for
128 : // accessibility.)
129 : slidesorter::SlideSorterViewShell* pSlideSorterViewShell
130 0 : = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
131 0 : if (pSlideSorterViewShell != NULL)
132 : {
133 0 : pSlideSorterViewShell->GetSlideSorter().GetController().PageNameHasChanged(
134 0 : nPageId-1, rName);
135 0 : }
136 : }
137 :
138 0 : return bSuccess;
139 : }
140 :
141 0 : IMPL_LINK( DrawViewShell, RenameSlideHdl, AbstractSvxNameDialog*, pDialog )
142 : {
143 0 : if( ! pDialog )
144 0 : return 0;
145 :
146 0 : OUString aNewName;
147 0 : pDialog->GetName( aNewName );
148 :
149 0 : SdPage* pCurrentPage = GetDoc()->GetSdPage( maTabControl.GetCurPageId() - 1, GetPageKind() );
150 :
151 0 : return long(pCurrentPage && ( aNewName == pCurrentPage->GetName() || GetDocSh()->IsNewPageNameValid( aNewName ) ));
152 : }
153 :
154 0 : void DrawViewShell::ModifyLayer (
155 : SdrLayer* pLayer,
156 : const OUString& rLayerName,
157 : const OUString& rLayerTitle,
158 : const OUString& rLayerDesc,
159 : bool bIsVisible,
160 : bool bIsLocked,
161 : bool bIsPrintable)
162 : {
163 0 : if(!GetLayerTabControl()) // #i87182#
164 : {
165 : OSL_ENSURE(false, "No LayerTabBar (!)");
166 0 : return;
167 : }
168 :
169 0 : if( pLayer )
170 : {
171 0 : const sal_uInt16 nPageCount = GetLayerTabControl()->GetPageCount();
172 0 : sal_uInt16 nCurPage = 0;
173 : sal_uInt16 nPos;
174 0 : for( nPos = 0; nPos < nPageCount; nPos++ )
175 : {
176 0 : sal_uInt16 nId = GetLayerTabControl()->GetPageId( nPos );
177 0 : if (GetLayerTabControl()->GetPageText(nId).equals(pLayer->GetName()))
178 : {
179 0 : nCurPage = nId;
180 0 : break;
181 : }
182 : }
183 :
184 0 : pLayer->SetName( rLayerName );
185 0 : pLayer->SetTitle( rLayerTitle );
186 0 : pLayer->SetDescription( rLayerDesc );
187 0 : mpDrawView->SetLayerVisible( rLayerName, bIsVisible );
188 0 : mpDrawView->SetLayerLocked( rLayerName, bIsLocked);
189 0 : mpDrawView->SetLayerPrintable(rLayerName, bIsPrintable);
190 :
191 0 : GetDoc()->SetChanged(true);
192 :
193 0 : GetLayerTabControl()->SetPageText(nCurPage, rLayerName);
194 :
195 0 : TabBarPageBits nBits = 0;
196 :
197 0 : if (!bIsVisible)
198 : {
199 : // invisible layers are presented different
200 0 : nBits = TPB_SPECIAL;
201 : }
202 :
203 0 : GetLayerTabControl()->SetPageBits(nCurPage, nBits);
204 :
205 : GetViewFrame()->GetDispatcher()->Execute(
206 : SID_SWITCHLAYER,
207 0 : SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
208 :
209 : // Call Invalidate at the form shell.
210 0 : FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
211 0 : if (pFormShell != NULL)
212 0 : pFormShell->Invalidate();
213 : }
214 : }
215 :
216 114 : } // end of namespace sd
217 :
218 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|