1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "precompiled_sd.hxx" 25 26 #include "SlsSelectionCommand.hxx" 27 28 #include "controller/SlsCurrentSlideManager.hxx" 29 #include "model/SlideSorterModel.hxx" 30 #include "model/SlsPageDescriptor.hxx" 31 32 #include "sdpage.hxx" 33 34 namespace sd { namespace slidesorter { namespace controller { 35 36 37 38 SelectionCommand::SelectionCommand ( 39 PageSelector& rSelector, 40 const ::boost::shared_ptr<CurrentSlideManager>& rpCurrentSlideManager, 41 const model::SlideSorterModel& rModel) 42 : mrPageSelector(rSelector), 43 mpCurrentSlideManager(rpCurrentSlideManager), 44 mrModel(rModel), 45 maPagesToSelect(), 46 mnCurrentPageIndex(-1) 47 { 48 } 49 50 51 52 53 void SelectionCommand::AddSlide (sal_uInt16 nPageIndex) 54 { 55 maPagesToSelect.push_back(nPageIndex); 56 } 57 58 59 60 61 void SelectionCommand::operator() (void) 62 { 63 OSL_ASSERT(mpCurrentSlideManager.get()!=NULL); 64 65 mrPageSelector.DeselectAllPages(); 66 67 if (mnCurrentPageIndex >= 0) 68 mpCurrentSlideManager->SwitchCurrentSlide(mnCurrentPageIndex); 69 70 PageList::iterator iPage = maPagesToSelect.begin(); 71 PageList::iterator iEnd = maPagesToSelect.end(); 72 for (; iPage!=iEnd; ++iPage) 73 { 74 sal_Int32 nIndex (*iPage); 75 if (nIndex >= 0) 76 mrPageSelector.SelectPage(mrModel.GetPageDescriptor(nIndex)); 77 } 78 } 79 80 81 } } } // end of namespace sd::slidesorter::controller 82