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 "model/SlsPageEnumerationProvider.hxx"
27 #include "model/SlsPageEnumeration.hxx"
28 #include "model/SlsPageDescriptor.hxx"
29 #include <boost/function.hpp>
30 
31 namespace sd { namespace slidesorter { namespace model {
32 
33 
34 namespace {
35 
36 class AllPagesPredicate
37 {
38 public:
operator ()(const SharedPageDescriptor & rpDescriptor)39     bool operator() (const SharedPageDescriptor& rpDescriptor)
40     {
41         (void)rpDescriptor;
42         return true;
43     }
44 };
45 
46 
47 
48 
49 
50 class SelectedPagesPredicate
51 {
52 public:
operator ()(const SharedPageDescriptor & rpDescriptor)53     bool operator() (const SharedPageDescriptor& rpDescriptor)
54     {
55         return rpDescriptor->HasState(PageDescriptor::ST_Selected);
56     }
57 };
58 
59 
60 
61 
62 class VisiblePagesPredicate
63 {
64 public:
operator ()(const SharedPageDescriptor & rpDescriptor)65     bool operator() (const SharedPageDescriptor& rpDescriptor)
66     {
67         return rpDescriptor->HasState(PageDescriptor::ST_Visible);
68     }
69 };
70 
71 }
72 
73 
74 
75 
CreateAllPagesEnumeration(const SlideSorterModel & rModel)76 PageEnumeration PageEnumerationProvider::CreateAllPagesEnumeration (
77     const SlideSorterModel& rModel)
78 {
79 //    AllPagesPredicate aPredicate; // spurious warning on unxsoli4 debug=t
80     return PageEnumeration::Create(rModel, AllPagesPredicate());
81 }
82 
83 
84 
85 
CreateSelectedPagesEnumeration(const SlideSorterModel & rModel)86 PageEnumeration PageEnumerationProvider::CreateSelectedPagesEnumeration (
87     const SlideSorterModel& rModel)
88 {
89     return PageEnumeration::Create(
90         rModel,
91         SelectedPagesPredicate());
92 }
93 
94 
95 
96 
CreateVisiblePagesEnumeration(const SlideSorterModel & rModel)97 PageEnumeration PageEnumerationProvider::CreateVisiblePagesEnumeration (
98     const SlideSorterModel& rModel)
99 {
100     return PageEnumeration::Create(
101         rModel,
102         VisiblePagesPredicate());
103 }
104 
105 
106 } } } // end of namespace ::sd::slidesorter::model
107