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