Update ooo320-m1
[ooovba.git] / sd / source / ui / slidesorter / inc / controller / SlsSelectionManager.hxx
blob0eec77af445244434fb1f95d115fd69ecaa9eaf8
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: SlsSelectionManager.hxx,v $
11 * $Revision: 1.3 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef SD_SLIDESORTER_CONTROLLER_SELECTION_MANAGER_HXX
33 #define SD_SLIDESORTER_CONTROLLER_SELECTION_MANAGER_HXX
35 #include "model/SlsSharedPageDescriptor.hxx"
36 #include <sal/types.h>
37 #include <tools/gen.hxx>
38 #include <vector>
40 class Link;
41 class SdPage;
43 namespace sd { namespace slidesorter {
44 class SlideSorter;
45 } }
47 namespace sd { namespace slidesorter { namespace controller {
49 class SlideSorterController;
51 /** This class is a part of the controller and handles the selection of
52 slides.
53 <p>It has methods to modify the selected slides (delete them or
54 move them to other places in the document), change the visible area so
55 to make the selected slides visble, tell listeners when the selection
56 changes.</p>
58 class SelectionManager
60 public:
61 /** Create a new SelectionManger for the given slide sorter.
63 SelectionManager (SlideSorter& rSlideSorter);
65 ~SelectionManager (void);
67 /** Delete the currently selected slides. When this method returns the
68 selection is empty.
70 void DeleteSelectedPages (void);
72 /** Move the maked pages to a position directly after the specified page.
74 bool MoveSelectedPages (const sal_Int32 nTargetPage);
76 /** Call this method after the selection has changed (possible several
77 calls to the PageSelector) to invalidate the relevant slots and send
78 appropriate events.
80 void SelectionHasChanged (const bool bMakeSelectionVisible = true);
82 /** Return <TRUE/> when the selection has changed but has not yet been
83 moved to the visible area of the slide sorter view.
85 bool IsMakeSelectionVisiblePending (void) const;
87 enum SelectionHint { SH_FIRST, SH_LAST, SH_RECENT };
89 /** Try to make all currently selected page objects visible, i.e. set
90 the origin so that the page objects lie inside the visible area.
91 When the selection is empty then the visible area is not modified.
93 <p>This method, and the ones is calls, look into the Properties
94 object of the SlideSorter in order to determine whether the current
95 selection is to be displayed centered.</p>
96 @param eSelectionHint
97 This is an advice on which selected page object to handle with
98 the highest priority when the whole selection does not fit into
99 the visible area.
100 @return
101 Returns the vertical translation of the visible area. It is 0
102 when no update of the visible area was done.
104 Size MakeSelectionVisible (
105 const SelectionHint eSelectionHint = SH_RECENT);
107 /** Modify the origin of the visible area so that the given rectangle
108 comes into view. This is done with the smallest change: no
109 scrolling takes place when the given rectangle already lies in the
110 visible area. Otherwise either the top or the bottom of the given
111 rectangle is aligned with the top or the bottom of the visible area.
112 @return
113 Returns the vertical translation of the visible area. It is 0
114 when no update of the visible area was done.
116 Size MakeRectangleVisible (const Rectangle& rBox);
118 /** Add a listener that is called when the selection of the slide sorter
119 changes.
120 @param rListener
121 When this method is called multiple times for the same listener
122 the second and all following calls are ignored. Each listener
123 is added only once.
125 void AddSelectionChangeListener (const Link& rListener);
127 /** Remove a listener that was called when the selection of the slide
128 sorter changes.
129 @param rListener
130 It is save to pass a listener that was not added are has been
131 removed previously. Such calls are ignored.
133 void RemoveSelectionChangeListener (const Link& rListener);
135 /** Return the position where to insert pasted slides based on the
136 current selection. When there is a selection then the insert
137 position is behind the last slide. When the selection is empty then
138 most of the time the insert position is at the end of the document.
139 There is an exception right after the display of a popup-menu. The
140 position of the associated insertion marker is stored here and reset
141 the next time the selection changes.
143 sal_Int32 GetInsertionPosition (void) const;
145 /** Store an insertion position temporarily. It is reset when the
146 selection changes the next time.
148 void SetInsertionPosition (const sal_Int32 nInsertionPosition);
150 private:
151 SlideSorter& mrSlideSorter;
152 SlideSorterController& mrController;
154 ::std::vector<Link> maSelectionChangeListeners;
156 /** This array stores the indices of the selected page descriptors at
157 the time when the edit mode is switched to EM_MASTERPAGE. With this
158 we can restore the selection when switching back to EM_PAGE mode.
160 ::std::vector<SdPage*> maSelectionBeforeSwitch;
162 /** When this flag is set then on the next call to Paint() the selection
163 is moved into the visible area.
165 bool mbIsMakeSelectionVisiblePending;
167 /** The insertion position is only temporarily valid. Negative values
168 indicate that the explicit insertion position is not valid. In this
169 case GetInsertionPosition() calculates it from the current selection.
171 sal_Int32 mnInsertionPosition;
173 /** Delete the given list of normal pages. This method is a helper
174 function for DeleteSelectedPages().
175 @param rSelectedNormalPages
176 A list of normal pages. Supplying master pages is an error.
178 void DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedNormalPages);
180 /** Delete the given list of master pages. This method is a helper
181 function for DeleteSelectedPages().
182 @param rSelectedMasterPages
183 A list of master pages. Supplying normal pages is an error.
185 void DeleteSelectedMasterPages (const ::std::vector<SdPage*>& rSelectedMasterPages);
187 /** Return <TRUE/> when the given rectangle, that typically is the
188 bounding box of all currently selected slides, does not fit entirely
189 into the visible area of the slide sorter view.
191 bool DoesSelectionExceedVisibleArea (const Rectangle& rSelectionBox) const;
193 /** When not all currently selected slides fit into the visible area of
194 the slide sorter view, and thus DoesSelectionExceedVisibleArea()
195 would return <TRUE/>, then it is the task of this method to
196 determine which part of the selection to move into the visible area.
197 @param rpFirst
198 The first selected slide. Must not be an empty pointer.
199 @param rpLast
200 The last selected slide. Must not be an empty pointer.
201 @param eSelectionHint
202 This hint tells the method on which slide to concentrate,
203 i.e. which slide has to be inside the returned visible area.
204 @return
205 Returns the new visible area.
207 Rectangle ResolveLargeSelection (
208 const model::SharedPageDescriptor& rpFirst,
209 const model::SharedPageDescriptor& rpLast,
210 const SelectionHint eSelectionHint);
213 } } } // end of namespace ::sd::slidesorter::controller
215 #endif