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 #ifndef SD_SLIDESORTER_SELECTION_COMMAND_HXX
25 #define SD_SLIDESORTER_SELECTION_COMMAND_HXX
26 
27 #include "controller/SlsPageSelector.hxx"
28 #include "SlsCommand.hxx"
29 #include <tools/solar.h>
30 #include <com/sun/star/drawing/XDrawPage.hpp>
31 
32 #include <boost/shared_ptr.hpp>
33 #include <vector>
34 
35 namespace sd { namespace slidesorter { namespace model {
36 class SlideSorterModel;
37 } } }
38 
39 
40 namespace sd { namespace slidesorter { namespace controller {
41 
42 class CurrentSlideManager;
43 class PageSelector;
44 
45 /** The SelectionCommand stores a list of pages that it will select on its
46     execution.  Furthermore it will make a page the current page.  Note that
47     internally pages are stored with pointers because this command is designed
48     to be executed after model changes where page indices may change but
49     page object identities remain.
50 */
51 class SelectionCommand
52     : public Command
53 {
54 public:
55     /** Create a new command object that will on its execution use the given
56         PageSelector to select a set of pages.
57     */
58     SelectionCommand (
59         PageSelector& rSelector,
60         const ::boost::shared_ptr<controller::CurrentSlideManager>& rpCurrentSlideManager,
61         const model::SlideSorterModel& rModel);
62 
63     /** Remember the specified page to be selected when this command is
64         executed.
65     */
66     void AddSlide (sal_uInt16 nPageIndex);
67 
68     /** Execute the command and select the pages added by previous calls to
69         AddPages() and AddPage().
70     */
71     virtual void operator() (void);
72 
73 private:
74     /// The page selector is used to select pages and set the current page.
75     PageSelector& mrPageSelector;
76     /// Used for setting the current slide.
77     ::boost::shared_ptr<controller::CurrentSlideManager> mpCurrentSlideManager;
78     /// The model is used to translate page indices into page pointers.
79     const model::SlideSorterModel& mrModel;
80     /// The list of pages to be selected when the command is executed.
81     typedef ::std::vector<sal_Int32> PageList;
82     PageList maPagesToSelect;
83     /** The page that will be made the current page when the command is
84         executed.
85     */
86     sal_Int32 mnCurrentPageIndex;
87 };
88 
89 } } } // end of namespace sd::slidesorter::controller
90 
91 #endif
92