android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / func / fusldlg.cxx
blobddb8f2ccf7cb00d5210022ee873131005423ec44
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/eitem.hxx>
22 #include <svl/itemset.hxx>
23 #include <svl/stritem.hxx>
24 #include <svl/intitem.hxx>
26 #include <drawdoc.hxx>
27 #include <sdpage.hxx>
28 #include <sdresid.hxx>
29 #include <strings.hrc>
30 #include <sdattr.hrc>
31 #include <sdmod.hxx>
32 #include <Window.hxx>
33 #include <optsitem.hxx>
34 #include <sdabstdlg.hxx>
36 namespace sd {
38 #define ITEMVALUE(ItemSet,Id,Cast) static_cast<const Cast&>((ItemSet).Get(Id)).GetValue()
41 FuSlideShowDlg::FuSlideShowDlg (
42 ViewShell* pViewSh,
43 ::sd::Window* pWin,
44 ::sd::View* pView,
45 SdDrawDocument* pDoc,
46 SfxRequest& rReq)
47 : FuPoor( pViewSh, pWin, pView, pDoc, rReq )
51 rtl::Reference<FuPoor> FuSlideShowDlg::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
53 rtl::Reference<FuPoor> xFunc( new FuSlideShowDlg( pViewSh, pWin, pView, pDoc, rReq ) );
54 xFunc->DoExecute(rReq);
55 return xFunc;
58 void FuSlideShowDlg::DoExecute( SfxRequest& )
60 PresentationSettings& rPresentationSettings = mpDoc->getPresentationSettings();
62 SfxItemSetFixed<ATTR_PRESENT_START, ATTR_PRESENT_END> aDlgSet( mpDoc->GetPool() );
63 std::vector<OUString> aPageNameList(mpDoc->GetSdPageCount( PageKind::Standard ));
64 const OUString& rPresPage = rPresentationSettings.maPresPage;
65 OUString aFirstPage;
66 SdPage* pPage = nullptr;
67 ::tools::Long nPage;
69 for( nPage = mpDoc->GetSdPageCount( PageKind::Standard ) - 1; nPage >= 0; nPage-- )
71 pPage = mpDoc->GetSdPage( static_cast<sal_uInt16>(nPage), PageKind::Standard );
72 OUString aStr( pPage->GetName() );
74 if ( aStr.isEmpty() )
76 aStr = SdResId( STR_PAGE ) + OUString::number( nPage + 1 );
79 aPageNameList[ nPage ] = aStr;
81 // is this our (existing) first page?
82 if ( rPresPage == aStr )
83 aFirstPage = rPresPage;
84 else if ( pPage->IsSelected() && aFirstPage.isEmpty() )
85 aFirstPage = aStr;
87 SdCustomShowList* pCustomShowList = mpDoc->GetCustomShowList(); // No Create
89 if( aFirstPage.isEmpty() && pPage )
90 aFirstPage = pPage->GetName();
92 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALL, rPresentationSettings.mbAll ) );
93 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CUSTOMSHOW, rPresentationSettings.mbCustomShow ) );
94 aDlgSet.Put( SfxStringItem( ATTR_PRESENT_DIANAME, aFirstPage ) );
95 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ENDLESS, rPresentationSettings.mbEndless ) );
96 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MANUEL, rPresentationSettings.mbManual ) );
97 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_MOUSE, rPresentationSettings.mbMouseVisible ) );
98 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_PEN, rPresentationSettings.mbMouseAsPen ) );
99 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ANIMATION_ALLOWED, rPresentationSettings.mbAnimationAllowed ) );
100 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_CHANGE_PAGE, !rPresentationSettings.mbLockedPages ) );
101 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_ALWAYS_ON_TOP, rPresentationSettings.mbAlwaysOnTop ) );
102 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_SHOW_NAVIGATION_BUTTONS, rPresentationSettings.mbUseNavigation ) );
103 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_FULLSCREEN, rPresentationSettings.mbFullScreen ) );
104 aDlgSet.Put( SfxUInt32Item( ATTR_PRESENT_PAUSE_TIMEOUT, rPresentationSettings.mnPauseTimeout ) );
105 aDlgSet.Put( SfxBoolItem( ATTR_PRESENT_SHOW_PAUSELOGO, rPresentationSettings.mbShowPauseLogo ) );
107 SdOptions* pOptions = SD_MOD()->GetSdOptions(DocumentType::Impress);
108 aDlgSet.Put( SfxInt32Item( ATTR_PRESENT_DISPLAY, pOptions->GetDisplay() ) );
110 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
111 ScopedVclPtr<AbstractSdStartPresDlg> pDlg( pFact->CreateSdStartPresentationDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr, aDlgSet, aPageNameList, pCustomShowList) );
112 if( pDlg->Execute() != RET_OK )
113 return;
115 ::tools::Long nValue32;
116 bool bValue;
117 bool bValuesChanged = false;
119 pDlg->GetAttr( aDlgSet );
121 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALL, SfxBoolItem );
122 if ( bValue != rPresentationSettings.mbAll )
124 bValuesChanged = true;
125 rPresentationSettings.mbAll = bValue;
126 // remove any previous existing slide
127 rPresentationSettings.maPresPage.clear();
130 if (!rPresentationSettings.mbAll)
132 OUString aPage = aDlgSet.Get(ATTR_PRESENT_DIANAME).GetValue();
133 if( aPage != rPresentationSettings.maPresPage )
135 bValuesChanged = true;
136 rPresentationSettings.maPresPage = aPage;
140 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_CUSTOMSHOW, SfxBoolItem );
141 if ( bValue != rPresentationSettings.mbCustomShow )
143 bValuesChanged = true;
144 rPresentationSettings.mbCustomShow = bValue;
145 rPresentationSettings.mbStartCustomShow = false;
148 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ENDLESS, SfxBoolItem );
149 if ( bValue != rPresentationSettings.mbEndless )
151 bValuesChanged = true;
152 rPresentationSettings.mbEndless = bValue;
155 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MANUEL, SfxBoolItem );
156 if ( bValue != rPresentationSettings.mbManual )
158 bValuesChanged = true;
159 rPresentationSettings.mbManual = bValue;
162 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MOUSE, SfxBoolItem );
163 if ( bValue != rPresentationSettings.mbMouseVisible )
165 bValuesChanged = true;
166 rPresentationSettings.mbMouseVisible = bValue;
169 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_PEN, SfxBoolItem );
170 if ( bValue != rPresentationSettings.mbMouseAsPen )
172 bValuesChanged = true;
173 rPresentationSettings.mbMouseAsPen = bValue;
176 bValue = !ITEMVALUE( aDlgSet, ATTR_PRESENT_CHANGE_PAGE, SfxBoolItem );
177 if ( bValue != rPresentationSettings.mbLockedPages )
179 bValuesChanged = true;
180 rPresentationSettings.mbLockedPages = bValue;
183 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ANIMATION_ALLOWED, SfxBoolItem );
184 if ( bValue != rPresentationSettings.mbAnimationAllowed )
186 bValuesChanged = true;
187 rPresentationSettings.mbAnimationAllowed = bValue;
190 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALWAYS_ON_TOP, SfxBoolItem );
191 if ( bValue != rPresentationSettings.mbAlwaysOnTop )
193 bValuesChanged = true;
194 rPresentationSettings.mbAlwaysOnTop = bValue;
197 bValue = ITEMVALUE(aDlgSet, ATTR_PRESENT_SHOW_NAVIGATION_BUTTONS, SfxBoolItem);
198 if (bValue != rPresentationSettings.mbUseNavigation)
200 bValuesChanged = true;
201 rPresentationSettings.mbUseNavigation = bValue;
204 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_FULLSCREEN, SfxBoolItem );
205 if ( bValue != rPresentationSettings.mbFullScreen )
207 bValuesChanged = true;
208 rPresentationSettings.mbFullScreen = bValue;
211 nValue32 = aDlgSet.Get(ATTR_PRESENT_PAUSE_TIMEOUT).GetValue();
212 if( nValue32 != rPresentationSettings.mnPauseTimeout )
214 bValuesChanged = true;
215 rPresentationSettings.mnPauseTimeout = nValue32;
218 bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_SHOW_PAUSELOGO, SfxBoolItem );
219 if ( bValue != rPresentationSettings.mbShowPauseLogo )
221 bValuesChanged = true;
222 rPresentationSettings.mbShowPauseLogo = bValue;
225 pOptions->SetDisplay( aDlgSet.Get(ATTR_PRESENT_DISPLAY).GetValue() );
227 // is something has changed, we set the modified flag
228 if ( bValuesChanged )
229 mpDoc->SetChanged();
232 } // end of namespace sd
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */