Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sd / source / ui / func / fusldlg.cxx
blob1a5ee50eb6b796f5d483b79642acf1cc139b492e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <fusldlg.hxx>
21 #include <svl/itemset.hxx>
23 #include <drawdoc.hxx>
24 #include <sdpage.hxx>
25 #include <sdresid.hxx>
26 #include <strings.hrc>
27 #include <sdattr.hxx>
28 #include <sdmod.hxx>
29 #include <ViewShell.hxx>
30 #include <Window.hxx>
31 #include <optsitem.hxx>
32 #include <sdabstdlg.hxx>
33 #include <memory>
35 namespace sd {
37 #define ITEMVALUE(ItemSet,Id,Cast) static_cast<const Cast&>((ItemSet).Get(Id)).GetValue()
40 FuSlideShowDlg::FuSlideShowDlg (
41 ViewShell* pViewSh,
42 ::sd::Window* pWin,
43 ::sd::View* pView,
44 SdDrawDocument* pDoc,
45 SfxRequest& rReq)
46 : FuPoor( pViewSh, pWin, pView, pDoc, rReq )
50 rtl::Reference<FuPoor> FuSlideShowDlg::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
52 rtl::Reference<FuPoor> xFunc( new FuSlideShowDlg( pViewSh, pWin, pView, pDoc, rReq ) );
53 xFunc->DoExecute(rReq);
54 return xFunc;
57 void FuSlideShowDlg::DoExecute( SfxRequest& )
59 PresentationSettings& rPresentationSettings = mpDoc->getPresentationSettings();
61 SfxItemSet aDlgSet( mpDoc->GetPool(), svl::Items<ATTR_PRESENT_START, ATTR_PRESENT_END>{} );
62 std::vector<OUString> aPageNameList(mpDoc->GetSdPageCount( PageKind::Standard ));
63 const OUString& rPresPage = rPresentationSettings.maPresPage;
64 OUString aFirstPage;
65 SdPage* pPage = nullptr;
66 long nPage;
68 for( nPage = mpDoc->GetSdPageCount( PageKind::Standard ) - 1; nPage >= 0; nPage-- )
70 pPage = mpDoc->GetSdPage( static_cast<sal_uInt16>(nPage), PageKind::Standard );
71 OUString aStr( pPage->GetName() );
73 if ( aStr.isEmpty() )
75 aStr = SdResId( STR_PAGE ) + OUString::number( nPage + 1 );
78 aPageNameList[ nPage ] = aStr;
80 // is this our (existing) first page?
81 if ( rPresPage == aStr )
82 aFirstPage = rPresPage;
83 else if ( pPage->IsSelected() && aFirstPage.isEmpty() )
84 aFirstPage = aStr;
86 SdCustomShowList* pCustomShowList = mpDoc->GetCustomShowList(); // No Create
88 if( aFirstPage.isEmpty() && pPage )
89 aFirstPage = pPage->GetName();
91 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALL, rPresentationSettings.mbAll ) );
92 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CUSTOMSHOW, rPresentationSettings.mbCustomShow ) );
93 aDlgSet.Put( SfxStringItem( ATTR_PRESENT_DIANAME, aFirstPage ) );
94 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ENDLESS, rPresentationSettings.mbEndless ) );
95 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MANUEL, rPresentationSettings.mbManual ) );
96 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MOUSE, rPresentationSettings.mbMouseVisible ) );
97 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_PEN, rPresentationSettings.mbMouseAsPen ) );
98 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ANIMATION_ALLOWED, rPresentationSettings.mbAnimationAllowed ) );
99 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CHANGE_PAGE, !rPresentationSettings.mbLockedPages ) );
100 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALWAYS_ON_TOP, rPresentationSettings.mbAlwaysOnTop ) );
101 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_FULLSCREEN, rPresentationSettings.mbFullScreen ) );
102 aDlgSet.Put( SfxUInt32Item( ATTR_PRESENT_PAUSE_TIMEOUT, rPresentationSettings.mnPauseTimeout ) );
103 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_SHOW_PAUSELOGO, rPresentationSettings.mbShowPauseLogo ) );
105 SdOptions* pOptions = SD_MOD()->GetSdOptions(DocumentType::Impress);
106 aDlgSet.Put( SfxInt32Item( ATTR_PRESENT_DISPLAY, pOptions->GetDisplay() ) );
108 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
109 ScopedVclPtr<AbstractSdStartPresDlg> pDlg(pFact ? pFact->CreateSdStartPresentationDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr, aDlgSet, aPageNameList, pCustomShowList) : nullptr);
110 if( pDlg && (pDlg->Execute() == RET_OK) )
112 OUString aPage;
113 long nValue32;
114 bool bValue;
115 bool bValuesChanged = false;
117 pDlg->GetAttr( aDlgSet );
119 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALL, SfxBoolItem );
120 if ( bValue != rPresentationSettings.mbAll )
122 bValuesChanged = true;
123 rPresentationSettings.mbAll = bValue;
124 // remove any previous existing slide
125 rPresentationSettings.maPresPage.clear();
128 if (!rPresentationSettings.mbAll)
130 aPage = ITEMVALUE( aDlgSet, ATTR_PRESENT_DIANAME, SfxStringItem );
131 if( aPage != rPresentationSettings.maPresPage )
133 bValuesChanged = true;
134 rPresentationSettings.maPresPage = aPage;
138 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_CUSTOMSHOW, SfxBoolItem );
139 if ( bValue != rPresentationSettings.mbCustomShow )
141 bValuesChanged = true;
142 rPresentationSettings.mbCustomShow = bValue;
145 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ENDLESS, SfxBoolItem );
146 if ( bValue != rPresentationSettings.mbEndless )
148 bValuesChanged = true;
149 rPresentationSettings.mbEndless = bValue;
152 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MANUEL, SfxBoolItem );
153 if ( bValue != rPresentationSettings.mbManual )
155 bValuesChanged = true;
156 rPresentationSettings.mbManual = bValue;
159 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MOUSE, SfxBoolItem );
160 if ( bValue != rPresentationSettings.mbMouseVisible )
162 bValuesChanged = true;
163 rPresentationSettings.mbMouseVisible = bValue;
166 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_PEN, SfxBoolItem );
167 if ( bValue != rPresentationSettings.mbMouseAsPen )
169 bValuesChanged = true;
170 rPresentationSettings.mbMouseAsPen = bValue;
173 bValue = !ITEMVALUE( aDlgSet, ATTR_PRESENT_CHANGE_PAGE, SfxBoolItem );
174 if ( bValue != rPresentationSettings.mbLockedPages )
176 bValuesChanged = true;
177 rPresentationSettings.mbLockedPages = bValue;
180 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ANIMATION_ALLOWED, SfxBoolItem );
181 if ( bValue != rPresentationSettings.mbAnimationAllowed )
183 bValuesChanged = true;
184 rPresentationSettings.mbAnimationAllowed = bValue;
187 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALWAYS_ON_TOP, SfxBoolItem );
188 if ( bValue != rPresentationSettings.mbAlwaysOnTop )
190 bValuesChanged = true;
191 rPresentationSettings.mbAlwaysOnTop = bValue;
194 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_FULLSCREEN, SfxBoolItem );
195 if ( bValue != rPresentationSettings.mbFullScreen )
197 bValuesChanged = true;
198 rPresentationSettings.mbFullScreen = bValue;
201 nValue32 = ITEMVALUE( aDlgSet, ATTR_PRESENT_PAUSE_TIMEOUT, SfxUInt32Item );
202 if( nValue32 != rPresentationSettings.mnPauseTimeout )
204 bValuesChanged = true;
205 rPresentationSettings.mnPauseTimeout = nValue32;
208 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_SHOW_PAUSELOGO, SfxBoolItem );
209 if ( bValue != rPresentationSettings.mbShowPauseLogo )
211 bValuesChanged = true;
212 rPresentationSettings.mbShowPauseLogo = bValue;
215 pOptions->SetDisplay( ITEMVALUE( aDlgSet, ATTR_PRESENT_DISPLAY, SfxInt32Item ) );
217 // is something has changed, we set the modified flag
218 if ( bValuesChanged )
219 mpDoc->SetChanged();
223 } // end of namespace sd
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */