Update ooo320-m1
[ooovba.git] / sd / source / ui / slidesorter / inc / controller / SlideSorterController.hxx
blob7effc42514b462d9c8a5fc8ffac7eaad407ff7b9
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: SlideSorterController.hxx,v $
10 * $Revision: 1.19 $
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_SLIDE_SORTER_CONTROLLER_HXX
32 #define SD_SLIDESORTER_SLIDE_SORTER_CONTROLLER_HXX
34 #include "model/SlsSharedPageDescriptor.hxx"
35 #include "ViewShell.hxx"
37 #include <com/sun/star/drawing/XDrawPages.hpp>
39 #include <sfx2/shell.hxx>
40 #include <sfx2/viewfac.hxx>
41 #include <tools/link.hxx>
42 #include <tools/gen.hxx>
43 #include <memory>
44 #include <comphelper/implementationreference.hxx>
46 namespace sd { namespace slidesorter {
47 class SlideSorter;
48 } }
50 namespace sd { namespace slidesorter { namespace view {
51 class SlideSorterView;
52 class HighlightObject;
53 } } }
55 namespace sd { namespace slidesorter { namespace model {
56 class SlideSorterModel;
57 } } }
59 namespace css = ::com::sun::star;
61 namespace sd { namespace slidesorter { namespace controller {
63 class Animator;
64 class Clipboard;
65 class CurrentSlideManager;
66 class FocusManager;
67 class Listener;
68 class PageSelector;
69 class Properties;
70 class ScrollBarManager;
71 class SelectionManager;
72 class SlotManager;
74 class SlideSorterController
76 public:
77 /** Create a new controller for the slide sorter.
78 @param pParentWindow
79 The window that contains the controls of the new
80 controller.
82 SlideSorterController (SlideSorter& rSlideSorter);
84 /** Late initialization. Call this method once a new new object has been
85 created.
87 virtual void Init (void);
89 virtual ~SlideSorterController (void);
91 /** Place and size the scroll bars and the browser window so that the
92 given rectangle is filled.
93 @return
94 The space occupied by the browser window is returned.
96 Rectangle Resize (const Rectangle& rAvailableSpace);
98 /** Determine which of the UI elements--the scroll bars, the scroll bar
99 filler, the actual slide sorter view--are visible and place them in
100 the area last passed to Resize().
101 @param bForce
102 When <TRUE/> is given (<FALSE/> is the default) then the content
103 window and with it the SlideSorterView is resized event when its
104 size does not change (the size does change when the visibility
105 of scroll bars changes.)
106 @return
107 Returns the space occupied by the browser window.
109 Rectangle Rearrange (bool bForce = false);
111 SlideSorter& GetSlideSorter (void) const;
113 /** Return the descriptor of the page that is rendered under the
114 given position.
115 @return
116 Returns a pointer to a page descriptor instead of a
117 reference because when no page is found at the position
118 then NULL is returned to indicate this.
120 model::SharedPageDescriptor GetPageAt (const Point& rPixelPosition);
122 /** Return the descriptor of the page that is associated to the page
123 visible fade symbol at the given position.
124 @return
125 When the given position is not over a visible page fade symbol
126 then NULL is returned.
128 model::SharedPageDescriptor GetFadePageAt (const Point& rPixelPosition);
130 PageSelector& GetPageSelector (void);
131 FocusManager& GetFocusManager (void);
132 controller::Clipboard& GetClipboard (void);
134 /** Return the object that manages the scroll bars.
136 ScrollBarManager& GetScrollBarManager (void);
138 ::boost::shared_ptr<CurrentSlideManager> GetCurrentSlideManager (void) const;
139 ::boost::shared_ptr<SlotManager> GetSlotManager (void) const;
140 ::boost::shared_ptr<SelectionManager> GetSelectionManager (void) const;
142 // forward VCLs PrePaint window event to DrawingLayer
143 void PrePaint();
145 /** This method forwards the call to the SlideSorterView and executes
146 pending operations like moving selected pages into the visible area.
148 void Paint (const Rectangle& rRect, ::Window* pWin);
150 void FuTemporary (SfxRequest& rRequest);
151 void FuPermanent (SfxRequest& rRequest);
152 void FuSupport (SfxRequest& rRequest);
153 bool Command (
154 const CommandEvent& rEvent,
155 ::sd::Window* pWindow);
157 void GetCtrlState (SfxItemSet &rSet);
158 void GetStatusBarState (SfxItemSet& rSet);
160 void ExecCtrl (SfxRequest& rRequest);
161 void GetAttrState (SfxItemSet& rSet);
162 void ExecStatusBar (SfxRequest& rRequest);
164 bool IsLocked (void) const;
166 /** Create an object of this inner class to prevent updates due to model
167 changes.
169 class ModelChangeLock
170 {public:
171 ModelChangeLock (SlideSorterController& rController);
172 ~ModelChangeLock (void);
173 void Release (void);
174 private:
175 SlideSorterController* mpController;
177 friend class ModelChangeLock;
180 /** Handle a change of the model, that is, handle the removal and
181 insertion of whole pages or a change of the edit mode.
183 This method is a convenience function that simply calls
184 PreModelChange() and then PostModelChange().
186 void HandleModelChange (void);
188 DECL_LINK(WindowEventHandler, VclWindowEvent*);
190 /** Update the display of all pages. This involves a redraw and
191 releasing previews and caches.
193 void UpdateAllPages (void);
195 /** Set the zoom factor. The given value is clipped against an upper
196 bound.
197 @param nZoom
198 An integer percent value, i.e. nZoom/100 is the actual zoom
199 factor.
201 void SetZoom (long int nZoom);
203 /** This factory method creates a selection function.
205 virtual FunctionReference CreateSelectionFunction (SfxRequest& rRequest);
207 /** Prepare for a change of the edit mode. Depending on the current
208 edit mode we may save the selection so that it can be restored when
209 later changing back to the current edit mode.
211 void PrepareEditModeChange (void);
213 /** Set a new edit mode and return whether the edit mode really
214 has been changed. For proper saving and restoring of the selection
215 this method should be called between calls to
216 PrepareEditModeChange() and FinishEditModeChange().
217 @return
218 A return value of <TRUE/> indicates that the edit mode has
219 changed.
221 bool ChangeEditMode (EditMode eEditMode);
223 /** Finish the change of the edit mode. Here we may select a page or
224 restore a previously saved selection.
226 void FinishEditModeChange (void);
228 /** Call this method when the name of one of the pages has changed.
229 This is then notified to the accessibility object, when that exists.
230 @param nPageIndex
231 The index of the page whose name has been changed.
232 @param rsOldName
233 The old name of the page. The new name can be taken from the
234 page object.
236 void PageNameHasChanged (int nPageIndex, const String& rsOldName);
238 /** Return whether a context menu has been opened by the called
239 SlideSorterController object and is still open.
241 bool IsContextMenuOpen (void) const;
243 /** Return a collection of properties that are used througout the slide
244 sorter.
246 ::boost::shared_ptr<Properties> GetProperties (void) const;
248 /** Provide the set of pages to be displayed in the slide sorter. The
249 GetDocumentSlides() method can be found only in the SlideSorterModel.
251 void SetDocumentSlides (const css::uno::Reference<css::container::XIndexAccess>& rxSlides);
253 /** Return an Animator object.
255 ::boost::shared_ptr<Animator> GetAnimator (void) const;
257 private:
258 SlideSorter& mrSlideSorter;
259 model::SlideSorterModel& mrModel;
260 view::SlideSorterView& mrView;
261 ::std::auto_ptr<PageSelector> mpPageSelector;
262 ::std::auto_ptr<FocusManager> mpFocusManager;
263 ::boost::shared_ptr<SlotManager> mpSlotManager;
264 ::std::auto_ptr<controller::Clipboard> mpClipboard;
265 ::std::auto_ptr<ScrollBarManager> mpScrollBarManager;
266 mutable ::boost::shared_ptr<CurrentSlideManager> mpCurrentSlideManager;
267 ::boost::shared_ptr<SelectionManager> mpSelectionManager;
268 ::boost::shared_ptr<Animator> mpAnimator;
270 // The listener listens to UNO events and thus is a UNO object.
271 // For proper life time management and at the same time free access to
272 // the implementation object we use the ImplementationReference class.
273 ::rtl::Reference<controller::Listener> mpListener;
275 int mnModelChangeLockCount;
277 bool mbPreModelChangeDone;
278 bool mbPostModelChangePending;
280 ::std::vector<Link> maSelectionChangeListeners;
282 /** This array stores the indices of the selected page descriptors at
283 the time when the edit mode is switched to EM_MASTERPAGE. With this
284 we can restore the selection when switching back to EM_PAGE mode.
286 ::std::vector<SdPage*> maSelectionBeforeSwitch;
287 /// The current page before the edit mode is switched to EM_MASTERPAGE.
288 int mnCurrentPageBeforeSwitch;
290 /** The master page to select after the edit mode is changed. This
291 member is used to pass the pointer from PrepareEditModeChange() to
292 FinishEditModeChange().
294 SdPage* mpEditModeChangeMasterPage;
296 /** This rectangle in the parent window encloses scroll bars and slide
297 sorter window. It is set when Resize() is called.
299 Rectangle maTotalWindowArea;
301 /** This counter is used to avoid processing of reentrant calls to
302 Paint().
304 sal_Int32 mnPaintEntranceCount;
306 /** Remember whether the context menu is open.
308 bool mbIsContextMenuOpen;
310 /** Some slide sorter wide properties that are used in different
311 classes.
313 ::boost::shared_ptr<Properties> mpProperties;
315 /** Delete the given list of normal pages. This method is a helper
316 function for DeleteSelectedPages().
317 @param rSelectedNormalPages
318 A list of normal pages. Supplying master pages is an error.
320 void DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedNormalPages);
322 /** Delete the given list of master pages. This method is a helper
323 function for DeleteSelectedPages().
324 @param rSelectedMasterPages
325 A list of master pages. Supplying normal pages is an error.
327 void DeleteSelectedMasterPages (const ::std::vector<SdPage*>& rSelectedMasterPages);
329 /** Prepare for several model changes, i.e. prevent time-consuming and
330 non-critical operations like repaints until UnlockModelChange() is
331 called. Ciritcal operations like releasing references to pages that
332 do not exist anymore are executed.
334 void LockModelChange (void);
336 /** Further calls to HandleModelChange() will result in a full featured
337 update of model, view, and controller. When HandleModelChange() has
338 been called since the last LockModelChange() then this is done right
339 away to bring the view up-to-date.
341 void UnlockModelChange (void);
343 /** Prepare for a model change. This method does all the things that
344 need to be done _before_ the model changes, e.g. because they need
345 access to the model data before the change.
347 void PreModelChange (void);
349 /** Complete a model change. This includes the recreation of data
350 structures that depend on the model and the request for a repaint to
351 show the changes.
353 void PostModelChange (void);
356 } } } // end of namespace ::sd::slidesorter::controller
358 #endif