1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "precompiled_sd.hxx" 29 30 #include "SlsHideSlideFunction.hxx" 31 32 #include "SlideSorter.hxx" 33 #include "model/SlsPageEnumerationProvider.hxx" 34 #include "model/SlsPageDescriptor.hxx" 35 #include "view/SlideSorterView.hxx" 36 37 #include "app.hrc" 38 #include "drawdoc.hxx" 39 #include "sdpage.hxx" 40 #include "ViewShell.hxx" 41 42 #include <sfx2/viewfrm.hxx> 43 #include <sfx2/bindings.hxx> 44 #include <sfx2/request.hxx> 45 #include <svx/svxids.hrc> 46 47 namespace sd { namespace slidesorter { namespace controller { 48 49 TYPEINIT1(HideSlideFunction, SlideFunction); 50 51 HideSlideFunction::HideSlideFunction ( 52 SlideSorter& rSlideSorter, 53 SfxRequest& rRequest) 54 : SlideFunction( rSlideSorter, rRequest), 55 mrSlideSorter(rSlideSorter) 56 { 57 } 58 59 60 61 62 HideSlideFunction::~HideSlideFunction (void) 63 { 64 } 65 66 67 68 69 FunctionReference HideSlideFunction::Create ( 70 SlideSorter& rSlideSorter, 71 SfxRequest& rRequest ) 72 { 73 FunctionReference xFunc( new HideSlideFunction( rSlideSorter, rRequest ) ); 74 xFunc->DoExecute(rRequest); 75 return xFunc; 76 } 77 78 79 80 81 void HideSlideFunction::DoExecute (SfxRequest& rRequest) 82 { 83 SlideFunction::DoExecute(rRequest); 84 85 model::PageEnumeration aSelectedPages ( 86 model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel())); 87 88 ExclusionState eState (UNDEFINED); 89 90 switch (rRequest.GetSlot()) 91 { 92 case SID_HIDE_SLIDE: 93 eState = EXCLUDED; 94 break; 95 96 case SID_SHOW_SLIDE: 97 eState = INCLUDED; 98 break; 99 100 default: 101 eState = UNDEFINED; 102 break; 103 } 104 105 if (eState != UNDEFINED) 106 { 107 // Set status at the selected pages. 108 aSelectedPages.Rewind (); 109 while (aSelectedPages.HasMoreElements()) 110 { 111 model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); 112 static_cast<view::SlideSorterView*>(mpView)->SetState( 113 pDescriptor, 114 model::PageDescriptor::ST_Excluded, 115 eState==EXCLUDED); 116 } 117 } 118 119 SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings(); 120 rBindings.Invalidate (SID_PRESENTATION); 121 rBindings.Invalidate (SID_REHEARSE_TIMINGS); 122 rBindings.Invalidate (SID_HIDE_SLIDE); 123 rBindings.Invalidate (SID_SHOW_SLIDE); 124 mpDoc->SetChanged(); 125 } 126 127 128 129 130 HideSlideFunction::ExclusionState HideSlideFunction::GetExclusionState ( 131 model::PageEnumeration& rPageSet) 132 { 133 ExclusionState eState (UNDEFINED); 134 sal_Bool bState; 135 136 // Get toggle state of the selected pages. 137 while (rPageSet.HasMoreElements() && eState!=MIXED) 138 { 139 bState = rPageSet.GetNextElement()->GetPage()->IsExcluded(); 140 switch (eState) 141 { 142 case UNDEFINED: 143 // Use the first selected page to set the inital value. 144 eState = bState ? EXCLUDED : INCLUDED; 145 break; 146 147 case EXCLUDED: 148 // The pages before where all not part of the show, 149 // this one is. 150 if ( ! bState) 151 eState = MIXED; 152 break; 153 154 case INCLUDED: 155 // The pages before where all part of the show, 156 // this one is not. 157 if (bState) 158 eState = MIXED; 159 break; 160 161 case MIXED: 162 default: 163 // No need to change anything. 164 break; 165 } 166 } 167 168 return eState; 169 } 170 171 } } } // end of namespace ::sd::slidesorter::controller 172