15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
35b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
55b190011SAndrew Rist * distributed with this work for additional information
65b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
75b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist * "License"); you may not use this file except in compliance
95b190011SAndrew Rist * with the License. You may obtain a copy of the License at
105b190011SAndrew Rist *
115b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
125b190011SAndrew Rist *
135b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist * software distributed under the License is distributed on an
155b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist * KIND, either express or implied. See the License for the
175b190011SAndrew Rist * specific language governing permissions and limitations
185b190011SAndrew Rist * under the License.
195b190011SAndrew Rist *
205b190011SAndrew Rist *************************************************************/
215b190011SAndrew Rist
225b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "precompiled_sd.hxx"
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include "SlsHideSlideFunction.hxx"
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "SlideSorter.hxx"
29cdf0e10cSrcweir #include "model/SlsPageEnumerationProvider.hxx"
30cdf0e10cSrcweir #include "model/SlsPageDescriptor.hxx"
31cdf0e10cSrcweir #include "view/SlideSorterView.hxx"
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include "app.hrc"
34cdf0e10cSrcweir #include "drawdoc.hxx"
35cdf0e10cSrcweir #include "sdpage.hxx"
36cdf0e10cSrcweir #include "ViewShell.hxx"
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
39cdf0e10cSrcweir #include <sfx2/bindings.hxx>
40cdf0e10cSrcweir #include <sfx2/request.hxx>
41cdf0e10cSrcweir #include <svx/svxids.hrc>
42cdf0e10cSrcweir
43cdf0e10cSrcweir namespace sd { namespace slidesorter { namespace controller {
44cdf0e10cSrcweir
45cdf0e10cSrcweir TYPEINIT1(HideSlideFunction, SlideFunction);
46cdf0e10cSrcweir
HideSlideFunction(SlideSorter & rSlideSorter,SfxRequest & rRequest)47cdf0e10cSrcweir HideSlideFunction::HideSlideFunction (
48cdf0e10cSrcweir SlideSorter& rSlideSorter,
49cdf0e10cSrcweir SfxRequest& rRequest)
50cdf0e10cSrcweir : SlideFunction( rSlideSorter, rRequest),
51cdf0e10cSrcweir mrSlideSorter(rSlideSorter)
52cdf0e10cSrcweir {
53cdf0e10cSrcweir }
54cdf0e10cSrcweir
55cdf0e10cSrcweir
56cdf0e10cSrcweir
57cdf0e10cSrcweir
~HideSlideFunction(void)58cdf0e10cSrcweir HideSlideFunction::~HideSlideFunction (void)
59cdf0e10cSrcweir {
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
62cdf0e10cSrcweir
63cdf0e10cSrcweir
64cdf0e10cSrcweir
Create(SlideSorter & rSlideSorter,SfxRequest & rRequest)65cdf0e10cSrcweir FunctionReference HideSlideFunction::Create (
66cdf0e10cSrcweir SlideSorter& rSlideSorter,
67cdf0e10cSrcweir SfxRequest& rRequest )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir FunctionReference xFunc( new HideSlideFunction( rSlideSorter, rRequest ) );
70cdf0e10cSrcweir xFunc->DoExecute(rRequest);
71cdf0e10cSrcweir return xFunc;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
74cdf0e10cSrcweir
75cdf0e10cSrcweir
76cdf0e10cSrcweir
DoExecute(SfxRequest & rRequest)77cdf0e10cSrcweir void HideSlideFunction::DoExecute (SfxRequest& rRequest)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir SlideFunction::DoExecute(rRequest);
80cdf0e10cSrcweir
81cdf0e10cSrcweir model::PageEnumeration aSelectedPages (
82cdf0e10cSrcweir model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel()));
83cdf0e10cSrcweir
84cdf0e10cSrcweir ExclusionState eState (UNDEFINED);
85cdf0e10cSrcweir
86cdf0e10cSrcweir switch (rRequest.GetSlot())
87cdf0e10cSrcweir {
88cdf0e10cSrcweir case SID_HIDE_SLIDE:
89cdf0e10cSrcweir eState = EXCLUDED;
90cdf0e10cSrcweir break;
91cdf0e10cSrcweir
92cdf0e10cSrcweir case SID_SHOW_SLIDE:
93cdf0e10cSrcweir eState = INCLUDED;
94cdf0e10cSrcweir break;
95cdf0e10cSrcweir
96cdf0e10cSrcweir default:
97cdf0e10cSrcweir eState = UNDEFINED;
98cdf0e10cSrcweir break;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
101cdf0e10cSrcweir if (eState != UNDEFINED)
102cdf0e10cSrcweir {
103cdf0e10cSrcweir // Set status at the selected pages.
104cdf0e10cSrcweir aSelectedPages.Rewind ();
105cdf0e10cSrcweir while (aSelectedPages.HasMoreElements())
106cdf0e10cSrcweir {
107cdf0e10cSrcweir model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
108cdf0e10cSrcweir static_cast<view::SlideSorterView*>(mpView)->SetState(
109cdf0e10cSrcweir pDescriptor,
110cdf0e10cSrcweir model::PageDescriptor::ST_Excluded,
111cdf0e10cSrcweir eState==EXCLUDED);
112cdf0e10cSrcweir }
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
115cdf0e10cSrcweir SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
116cdf0e10cSrcweir rBindings.Invalidate (SID_PRESENTATION);
117cdf0e10cSrcweir rBindings.Invalidate (SID_REHEARSE_TIMINGS);
118cdf0e10cSrcweir rBindings.Invalidate (SID_HIDE_SLIDE);
119cdf0e10cSrcweir rBindings.Invalidate (SID_SHOW_SLIDE);
120cdf0e10cSrcweir mpDoc->SetChanged();
121cdf0e10cSrcweir }
122cdf0e10cSrcweir
123cdf0e10cSrcweir
124cdf0e10cSrcweir
125cdf0e10cSrcweir
GetExclusionState(model::PageEnumeration & rPageSet)126cdf0e10cSrcweir HideSlideFunction::ExclusionState HideSlideFunction::GetExclusionState (
127cdf0e10cSrcweir model::PageEnumeration& rPageSet)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir ExclusionState eState (UNDEFINED);
130cdf0e10cSrcweir sal_Bool bState;
131cdf0e10cSrcweir
132cdf0e10cSrcweir // Get toggle state of the selected pages.
133cdf0e10cSrcweir while (rPageSet.HasMoreElements() && eState!=MIXED)
134cdf0e10cSrcweir {
135cdf0e10cSrcweir bState = rPageSet.GetNextElement()->GetPage()->IsExcluded();
136cdf0e10cSrcweir switch (eState)
137cdf0e10cSrcweir {
138cdf0e10cSrcweir case UNDEFINED:
139*86e1cf34SPedro Giffuni // Use the first selected page to set the initial value.
140cdf0e10cSrcweir eState = bState ? EXCLUDED : INCLUDED;
141cdf0e10cSrcweir break;
142cdf0e10cSrcweir
143cdf0e10cSrcweir case EXCLUDED:
144cdf0e10cSrcweir // The pages before where all not part of the show,
145cdf0e10cSrcweir // this one is.
146cdf0e10cSrcweir if ( ! bState)
147cdf0e10cSrcweir eState = MIXED;
148cdf0e10cSrcweir break;
149cdf0e10cSrcweir
150cdf0e10cSrcweir case INCLUDED:
151cdf0e10cSrcweir // The pages before where all part of the show,
152cdf0e10cSrcweir // this one is not.
153cdf0e10cSrcweir if (bState)
154cdf0e10cSrcweir eState = MIXED;
155cdf0e10cSrcweir break;
156cdf0e10cSrcweir
157cdf0e10cSrcweir case MIXED:
158cdf0e10cSrcweir default:
159cdf0e10cSrcweir // No need to change anything.
160cdf0e10cSrcweir break;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
164cdf0e10cSrcweir return eState;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir } } } // end of namespace ::sd::slidesorter::controller
168