1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsHideSlideFunction.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "precompiled_sd.hxx"
33 #include "SlsHideSlideFunction.hxx"
35 #include "SlideSorter.hxx"
36 #include "model/SlsPageEnumerationProvider.hxx"
37 #include "model/SlsPageDescriptor.hxx"
38 #include "view/SlideSorterView.hxx"
41 #include "drawdoc.hxx"
43 #include "ViewShell.hxx"
45 #include <sfx2/viewfrm.hxx>
46 #include <sfx2/bindings.hxx>
47 #include <sfx2/request.hxx>
48 #include <svx/svxids.hrc>
50 namespace sd
{ namespace slidesorter
{ namespace controller
{
52 TYPEINIT1(HideSlideFunction
, SlideFunction
);
54 HideSlideFunction::HideSlideFunction (
55 SlideSorter
& rSlideSorter
,
57 : SlideFunction( rSlideSorter
, rRequest
),
58 mrSlideSorter(rSlideSorter
)
65 HideSlideFunction::~HideSlideFunction (void)
72 FunctionReference
HideSlideFunction::Create (
73 SlideSorter
& rSlideSorter
,
74 SfxRequest
& rRequest
)
76 FunctionReference
xFunc( new HideSlideFunction( rSlideSorter
, rRequest
) );
77 xFunc
->DoExecute(rRequest
);
84 void HideSlideFunction::DoExecute (SfxRequest
& rRequest
)
86 SlideFunction::DoExecute(rRequest
);
88 model::PageEnumeration
aSelectedPages (
89 model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter
.GetModel()));
91 ExclusionState
eState (UNDEFINED
);
93 switch (rRequest
.GetSlot())
108 if (eState
!= UNDEFINED
)
110 // Set status at the selected pages.
111 aSelectedPages
.Rewind ();
112 while (aSelectedPages
.HasMoreElements())
114 model::SharedPageDescriptor
pDescriptor (aSelectedPages
.GetNextElement());
115 pDescriptor
->GetPage()->SetExcluded (eState
==EXCLUDED
);
116 static_cast<view::SlideSorterView
*>(mpView
)->RequestRepaint(pDescriptor
);
120 SfxBindings
& rBindings
= mpViewShell
->GetViewFrame()->GetBindings();
121 rBindings
.Invalidate (SID_PRESENTATION
);
122 rBindings
.Invalidate (SID_REHEARSE_TIMINGS
);
123 rBindings
.Invalidate (SID_HIDE_SLIDE
);
124 rBindings
.Invalidate (SID_SHOW_SLIDE
);
131 HideSlideFunction::ExclusionState
HideSlideFunction::GetExclusionState (
132 model::PageEnumeration
& rPageSet
)
134 ExclusionState
eState (UNDEFINED
);
137 // Get toggle state of the selected pages.
138 while (rPageSet
.HasMoreElements() && eState
!=MIXED
)
140 bState
= rPageSet
.GetNextElement()->GetPage()->IsExcluded();
144 // Use the first selected page to set the inital value.
145 eState
= bState
? EXCLUDED
: INCLUDED
;
149 // The pages before where all not part of the show,
156 // The pages before where all part of the show,
164 // No need to change anything.
172 } } } // end of namespace ::sd::slidesorter::controller