merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / slidesorter / inc / model / SlsPageEnumeration.hxx
blobfdb54057fff017e69823572b55cd67179f86e281
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsPageEnumeration.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_SLIDESORTER_PAGE_ENUMERATION_HXX
32 #define SD_SLIDESORTER_PAGE_ENUMERATION_HXX
34 #include "pres.hxx"
37 #include "model/SlsEnumeration.hxx"
38 #include "model/SlsSharedPageDescriptor.hxx"
40 #include <boost/function.hpp>
41 #include <memory>
43 namespace sd { namespace slidesorter { namespace model {
45 class SlideSorterModel;
48 /** Public class of page enumerations that delegates its calls to an
49 implementation object that can filter pages by using a given predicate.
51 @see PageEnumerationProvider
52 The PageEnumerationProvider has methods for creating different types
53 of page enumerations.
55 class PageEnumeration
56 : public Enumeration<SharedPageDescriptor>
58 public:
59 /** Create a new page enumeration that enumerates a subset of the pages
60 of the given model.
61 @param rModel
62 The new page enumeration enumerates the pages of this model.
63 @param rPredicate
64 This predicate determines which pages to include in the
65 enumeration. Pages for which rPredicate returns <FALSE/> are
66 exclude.
68 typedef ::boost::function<bool(const SharedPageDescriptor&)> PagePredicate;
69 static PageEnumeration Create (
70 const SlideSorterModel& rModel,
71 const PagePredicate& rPredicate);
73 /** This copy constructor creates a copy of the given enumeration.
75 PageEnumeration (const PageEnumeration& rEnumeration);
77 virtual ~PageEnumeration();
79 /** Create a new enumeration object. The ownership of the
80 implementation object goes to the new object. Use this copy
81 constructor only when you know what you are doing. When in doubt,
82 use the one argument version.
83 @param bCloneImpl
84 When <TRUE/> is given this constructor behaves exactly like its
85 one argument version. When <FALSE/> is given then the
86 implementation object is not copied but moved from the given
87 enumeration to the newly created one. The given enumeration
88 thus becomes empty.
90 PageEnumeration (PageEnumeration& rEnumeration, bool bCloneImpl);
92 /** Create and return an exact copy of the called object.
94 virtual ::std::auto_ptr<Enumeration<SharedPageDescriptor> > Clone (void);
96 PageEnumeration& operator= (const PageEnumeration& rEnumeration);
98 /** Return <TRUE/> when the enumeration has more elements, i.e. it is
99 save to call GetNextElement() at least one more time.
101 virtual bool HasMoreElements (void) const;
103 /** Return the next element of the enumeration. Call the
104 HasMoreElements() before to make sure that there exists at least one
105 more element. Calling this method with HasMoreElements() returning
106 <FALSE/> is an error.
108 virtual SharedPageDescriptor GetNextElement (void);
110 /** Rewind the enumeration so that the next call to GetNextElement()
111 will return its first element.
113 virtual void Rewind (void);
115 private:
116 /// Implementation object.
117 ::std::auto_ptr<Enumeration<SharedPageDescriptor> > mpImpl;
119 /** This constructor expects an implementation object that holds
120 the predicate that filters the pages.
122 PageEnumeration (::std::auto_ptr<Enumeration<SharedPageDescriptor> > pImpl);
124 // Default constructor not implemented.
125 PageEnumeration (void);
128 } } } // end of namespace ::sd::slidesorter::model
130 #endif