merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / slidesorter / controller / SlsHideSlideFunction.cxx
blob8b1f1be9e55e71e3f65722af6c9bd00173f7e07c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsHideSlideFunction.cxx,v $
10 * $Revision: 1.10 $
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"
40 #include "app.hrc"
41 #include "drawdoc.hxx"
42 #include "sdpage.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,
56 SfxRequest& rRequest)
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);
78 return xFunc;
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())
95 case SID_HIDE_SLIDE:
96 eState = EXCLUDED;
97 break;
99 case SID_SHOW_SLIDE:
100 eState = INCLUDED;
101 break;
103 default:
104 eState = UNDEFINED;
105 break;
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);
125 mpDoc->SetChanged();
131 HideSlideFunction::ExclusionState HideSlideFunction::GetExclusionState (
132 model::PageEnumeration& rPageSet)
134 ExclusionState eState (UNDEFINED);
135 BOOL bState;
137 // Get toggle state of the selected pages.
138 while (rPageSet.HasMoreElements() && eState!=MIXED)
140 bState = rPageSet.GetNextElement()->GetPage()->IsExcluded();
141 switch (eState)
143 case UNDEFINED:
144 // Use the first selected page to set the inital value.
145 eState = bState ? EXCLUDED : INCLUDED;
146 break;
148 case EXCLUDED:
149 // The pages before where all not part of the show,
150 // this one is.
151 if ( ! bState)
152 eState = MIXED;
153 break;
155 case INCLUDED:
156 // The pages before where all part of the show,
157 // this one is not.
158 if (bState)
159 eState = MIXED;
160 break;
162 case MIXED:
163 default:
164 // No need to change anything.
165 break;
169 return eState;
172 } } } // end of namespace ::sd::slidesorter::controller