1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsPageSelector.hxx,v $
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_SELECTOR_HXX
32 #define SD_SLIDESORTER_PAGE_SELECTOR_HXX
34 #include "model/SlsSharedPageDescriptor.hxx"
36 #include <com/sun/star/drawing/XDrawPage.hpp>
42 namespace sd
{ namespace slidesorter
{
46 namespace sd
{ namespace slidesorter
{ namespace model
{
47 class SlideSorterModel
;
50 namespace sd
{ namespace slidesorter
{ namespace view
{
51 class SlideSorterView
;
54 namespace sd
{ namespace slidesorter
{ namespace controller
{
56 class SlideSorterController
;
59 /** A sub-controller that handles page selection of the slide browser.
60 Selecting a page does not make it the current page (of the main view)
61 automatically as this would not be desired in a multi selection. This
62 has to be done explicitly by calling the
63 CurrentSlideManager::SetCurrentSlide() method.
65 Indices of pages relate allways to the number of all pages in the model
66 (as returned by GetPageCount()) not just the selected pages.
71 PageSelector (SlideSorter
& rSlideSorter
);
73 void SelectAllPages (void);
74 void DeselectAllPages (void);
75 /** Update the selection state of all page descriptors to be the same as
76 that of the pages of the SdDrawDocument they describe and issue
77 redraw requests where necessary.
79 void UpdateAllPages (void);
81 void SelectPage (int nPageIndex
);
82 /** Select the descriptor that is associated with the given page.
84 void SelectPage (const SdPage
* pPage
);
85 void SelectPage (const model::SharedPageDescriptor
& rpDescriptor
);
87 /** Return whether the specified page is selected. This convenience
88 method is a subsitute for
89 SlideSorterModel::GetPageDescriptor(i)->IsSelected() is included
90 here to make this class more self contained.
92 bool IsPageSelected (int nPageIndex
);
94 /** Deselect the descriptor that is associated with the given page.
96 void DeselectPage (int nPageIndex
);
97 void DeselectPage (const SdPage
* pPage
);
98 void DeselectPage (const model::SharedPageDescriptor
& rpDescriptor
);
100 /** This convenience method returns the same number of pages that
101 SlideSorterModel.GetPageCount() returns. It is included here so
102 that it is self contained for iterating over all pages to select or
105 int GetPageCount (void) const;
106 int GetSelectedPageCount (void) const;
108 void PrepareModelChange (void);
109 void HandleModelChange (void);
111 /** Enable the broadcasting of selection change events. This calls the
112 SlideSorterController::SelectionHasChanged() method to do the actual
113 work. When EnableBroadcasting has been called as many times as
114 DisableBroadcasting() was called before and the selection has been
115 changed in the mean time, this change will be broadcasted.
117 void EnableBroadcasting (bool bMakeSelectionVisible
= true);
119 /** Disable the broadcasting o selectio change events. Subsequent
120 changes of the selection will set a flag that triggers the sending
121 of events when EnableBroadcasting() is called.
123 void DisableBroadcasting (void);
125 /** Return the descriptor of the most recently selected page. This
126 works only when the page has not been de-selected in the mean time.
127 This method helps the view when it scrolls the selection into the
130 When the selection is empty or when the most recently selected
131 page has been deselected already (but other pages are still
132 selected) then NULL is returned, even when a selection did exist
133 but has been cleared.
135 model::SharedPageDescriptor
GetMostRecentlySelectedPage (void) const;
137 /** Return the anchor for a range selection. This usually is the first
138 selected page after all pages have been deselected.
140 The returned anchor may be NULL.
142 model::SharedPageDescriptor
GetSelectionAnchor (void) const;
145 typedef ::std::vector
<SdPage
*> PageSelection
;
147 /** Return an object that describes the current selection. The caller
148 can use that object to later restore the selection.
150 The object returned describes the selection via indices. So
151 even if pages are exchanged a later call to SetPageSelection()
154 ::boost::shared_ptr
<PageSelection
> GetPageSelection (void) const;
156 /** Restore a page selection according to the given selection object.
158 Typically obtained by calling GetPageSelection() this object
159 is used to restore the selection. If pages were exchanged since
160 the last call to GetPageSelection() it is still valid to call
161 this method with the selection. When pages have been inserted
162 or removed the result may be unexpected.
164 void SetPageSelection (const ::boost::shared_ptr
<PageSelection
>& rSelection
);
166 void UpdateCurrentPage (const model::SharedPageDescriptor
& rCurrentPageDescriptor
);
169 model::SlideSorterModel
& mrModel
;
170 SlideSorter
& mrSlideSorter
;
171 SlideSorterController
& mrController
;
172 int mnSelectedPageCount
;
173 int mnBroadcastDisableLevel
;
174 bool mbSelectionChangeBroadcastPending
;
175 model::SharedPageDescriptor mpMostRecentlySelectedPage
;
176 /// Anchor for a range selection.
177 model::SharedPageDescriptor mpSelectionAnchor
;
178 model::SharedPageDescriptor mpCurrentPage
;
180 void CountSelectedPages (void);
183 } } } // end of namespace ::sd::slidesorter::controller