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 <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>
43 #include "strings.hrc"
44 #include "res_bmp.hrc"
46 #include "Outliner.hxx"
50 #include "drawdoc.hxx"
51 #include "DrawDocShell.hxx"
52 #include "sdresid.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"
68 bool DrawViewShell::RenameSlide( sal_uInt16 nPageId
, const OUString
& rName
)
71 if( GetDoc()->GetPageByName( rName
, bOutDummy
) != SDRPAGE_NOTFOUND
)
74 SdPage
* pPageToRename
= NULL
;
75 PageKind ePageKind
= GetPageKind();
77 if( GetEditMode() == EM_PAGE
)
79 pPageToRename
= GetDoc()->GetSdPage( nPageId
- 1, ePageKind
);
82 SdPage
* pUndoPage
= pPageToRename
;
83 SdrLayerAdmin
& rLayerAdmin
= GetDoc()->GetLayerAdmin();
84 sal_uInt8 nBackground
= rLayerAdmin
.GetLayerID( SD_RESSTR(STR_LAYER_BCKGRND
), false );
85 sal_uInt8 nBgObj
= rLayerAdmin
.GetLayerID( SD_RESSTR(STR_LAYER_BCKGRNDOBJ
), false );
86 SetOfByte aVisibleLayers
= mpActualPage
->TRG_GetMasterPageVisibleLayers();
88 ::svl::IUndoManager
* pManager
= GetDoc()->GetDocSh()->GetUndoManager();
89 ModifyPageUndoAction
* pAction
= new ModifyPageUndoAction(
90 GetDoc(), pUndoPage
, rName
, pUndoPage
->GetAutoLayout(),
91 aVisibleLayers
.IsSet( nBackground
),
92 aVisibleLayers
.IsSet( nBgObj
));
93 pManager
->AddUndoAction( pAction
);
96 pPageToRename
->SetName( rName
);
98 if( ePageKind
== PK_STANDARD
)
100 // also rename notes-page
101 SdPage
* pNotesPage
= GetDoc()->GetSdPage( nPageId
- 1, PK_NOTES
);
102 pNotesPage
->SetName( rName
);
107 // rename MasterPage -> rename LayoutTemplate
108 pPageToRename
= GetDoc()->GetMasterSdPage( nPageId
- 1, ePageKind
);
109 GetDoc()->RenameLayoutTemplate( pPageToRename
->GetLayoutName(), rName
);
112 bool bSuccess
= (rName
== pPageToRename
->GetName());
116 // user edited page names may be changed by the page so update control
117 maTabControl
->SetPageText( nPageId
, rName
);
119 // set document to modified state
120 GetDoc()->SetChanged( true );
122 // inform navigator about change
123 SfxBoolItem
aItem( SID_NAVIGATOR_INIT
, true );
124 GetViewFrame()->GetDispatcher()->Execute(
125 SID_NAVIGATOR_INIT
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
, &aItem
, 0L );
127 // Tell the slide sorter about the name change (necessary for
129 slidesorter::SlideSorterViewShell
* pSlideSorterViewShell
130 = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
131 if (pSlideSorterViewShell
!= NULL
)
133 pSlideSorterViewShell
->GetSlideSorter().GetController().PageNameHasChanged(
141 IMPL_LINK( DrawViewShell
, RenameSlideHdl
, AbstractSvxNameDialog
*, pDialog
)
147 pDialog
->GetName( aNewName
);
149 SdPage
* pCurrentPage
= GetDoc()->GetSdPage( maTabControl
->GetCurPageId() - 1, GetPageKind() );
151 return long(pCurrentPage
&& ( aNewName
== pCurrentPage
->GetName() || GetDocSh()->IsNewPageNameValid( aNewName
) ));
154 void DrawViewShell::ModifyLayer (
156 const OUString
& rLayerName
,
157 const OUString
& rLayerTitle
,
158 const OUString
& rLayerDesc
,
163 if(!GetLayerTabControl()) // #i87182#
165 OSL_ENSURE(false, "No LayerTabBar (!)");
171 const sal_uInt16 nPageCount
= GetLayerTabControl()->GetPageCount();
172 sal_uInt16 nCurPage
= 0;
174 for( nPos
= 0; nPos
< nPageCount
; nPos
++ )
176 sal_uInt16 nId
= GetLayerTabControl()->GetPageId( nPos
);
177 if (GetLayerTabControl()->GetPageText(nId
).equals(pLayer
->GetName()))
184 pLayer
->SetName( rLayerName
);
185 pLayer
->SetTitle( rLayerTitle
);
186 pLayer
->SetDescription( rLayerDesc
);
187 mpDrawView
->SetLayerVisible( rLayerName
, bIsVisible
);
188 mpDrawView
->SetLayerLocked( rLayerName
, bIsLocked
);
189 mpDrawView
->SetLayerPrintable(rLayerName
, bIsPrintable
);
191 GetDoc()->SetChanged(true);
193 GetLayerTabControl()->SetPageText(nCurPage
, rLayerName
);
195 TabBarPageBits nBits
= 0;
199 // invisible layers are presented different
203 GetLayerTabControl()->SetPageBits(nCurPage
, nBits
);
205 GetViewFrame()->GetDispatcher()->Execute(
207 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
209 // Call Invalidate at the form shell.
210 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
211 if (pFormShell
!= NULL
)
212 pFormShell
->Invalidate();
216 } // end of namespace sd
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */