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 <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>
28 #include <sdresid.hxx>
29 #include <strings.hrc>
33 #include <optsitem.hxx>
34 #include <sdabstdlg.hxx>
38 #define ITEMVALUE(ItemSet,Id,Cast) static_cast<const Cast&>((ItemSet).Get(Id)).GetValue()
41 FuSlideShowDlg::FuSlideShowDlg (
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
);
58 void FuSlideShowDlg::DoExecute( SfxRequest
& )
60 PresentationSettings
& rPresentationSettings
= mpDoc
->getPresentationSettings();
62 SfxItemSet
aDlgSet( mpDoc
->GetPool(), svl::Items
<ATTR_PRESENT_START
, ATTR_PRESENT_END
>{} );
63 std::vector
<OUString
> aPageNameList(mpDoc
->GetSdPageCount( PageKind::Standard
));
64 const OUString
& rPresPage
= rPresentationSettings
.maPresPage
;
66 SdPage
* pPage
= nullptr;
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() );
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() )
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_FULLSCREEN
, rPresentationSettings
.mbFullScreen
) );
103 aDlgSet
.Put( SfxUInt32Item( ATTR_PRESENT_PAUSE_TIMEOUT
, rPresentationSettings
.mnPauseTimeout
) );
104 aDlgSet
.Put( SfxBoolItem( ATTR_PRESENT_SHOW_PAUSELOGO
, rPresentationSettings
.mbShowPauseLogo
) );
106 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(DocumentType::Impress
);
107 aDlgSet
.Put( SfxInt32Item( ATTR_PRESENT_DISPLAY
, pOptions
->GetDisplay() ) );
109 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
110 ScopedVclPtr
<AbstractSdStartPresDlg
> pDlg( pFact
->CreateSdStartPresentationDlg(mpWindow
? mpWindow
->GetFrameWeld() : nullptr, aDlgSet
, aPageNameList
, pCustomShowList
) );
111 if( pDlg
->Execute() != RET_OK
)
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 aPage
= ITEMVALUE( aDlgSet
, ATTR_PRESENT_DIANAME
, SfxStringItem
);
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
;
147 bValue
= ITEMVALUE( aDlgSet
, ATTR_PRESENT_ENDLESS
, SfxBoolItem
);
148 if ( bValue
!= rPresentationSettings
.mbEndless
)
150 bValuesChanged
= true;
151 rPresentationSettings
.mbEndless
= bValue
;
154 bValue
= ITEMVALUE( aDlgSet
, ATTR_PRESENT_MANUEL
, SfxBoolItem
);
155 if ( bValue
!= rPresentationSettings
.mbManual
)
157 bValuesChanged
= true;
158 rPresentationSettings
.mbManual
= bValue
;
161 bValue
= ITEMVALUE( aDlgSet
, ATTR_PRESENT_MOUSE
, SfxBoolItem
);
162 if ( bValue
!= rPresentationSettings
.mbMouseVisible
)
164 bValuesChanged
= true;
165 rPresentationSettings
.mbMouseVisible
= bValue
;
168 bValue
= ITEMVALUE( aDlgSet
, ATTR_PRESENT_PEN
, SfxBoolItem
);
169 if ( bValue
!= rPresentationSettings
.mbMouseAsPen
)
171 bValuesChanged
= true;
172 rPresentationSettings
.mbMouseAsPen
= bValue
;
175 bValue
= !ITEMVALUE( aDlgSet
, ATTR_PRESENT_CHANGE_PAGE
, SfxBoolItem
);
176 if ( bValue
!= rPresentationSettings
.mbLockedPages
)
178 bValuesChanged
= true;
179 rPresentationSettings
.mbLockedPages
= bValue
;
182 bValue
= ITEMVALUE( aDlgSet
, ATTR_PRESENT_ANIMATION_ALLOWED
, SfxBoolItem
);
183 if ( bValue
!= rPresentationSettings
.mbAnimationAllowed
)
185 bValuesChanged
= true;
186 rPresentationSettings
.mbAnimationAllowed
= bValue
;
189 bValue
= ITEMVALUE( aDlgSet
, ATTR_PRESENT_ALWAYS_ON_TOP
, SfxBoolItem
);
190 if ( bValue
!= rPresentationSettings
.mbAlwaysOnTop
)
192 bValuesChanged
= true;
193 rPresentationSettings
.mbAlwaysOnTop
= bValue
;
196 bValue
= ITEMVALUE( aDlgSet
, ATTR_PRESENT_FULLSCREEN
, SfxBoolItem
);
197 if ( bValue
!= rPresentationSettings
.mbFullScreen
)
199 bValuesChanged
= true;
200 rPresentationSettings
.mbFullScreen
= bValue
;
203 nValue32
= ITEMVALUE( aDlgSet
, ATTR_PRESENT_PAUSE_TIMEOUT
, SfxUInt32Item
);
204 if( nValue32
!= rPresentationSettings
.mnPauseTimeout
)
206 bValuesChanged
= true;
207 rPresentationSettings
.mnPauseTimeout
= nValue32
;
210 bValue
= ITEMVALUE( aDlgSet
, ATTR_PRESENT_SHOW_PAUSELOGO
, SfxBoolItem
);
211 if ( bValue
!= rPresentationSettings
.mbShowPauseLogo
)
213 bValuesChanged
= true;
214 rPresentationSettings
.mbShowPauseLogo
= bValue
;
217 pOptions
->SetDisplay( ITEMVALUE( aDlgSet
, ATTR_PRESENT_DISPLAY
, SfxInt32Item
) );
219 // is something has changed, we set the modified flag
220 if ( bValuesChanged
)
224 } // end of namespace sd
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */