bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / slidesorter / inc / controller / SlideSorterController.hxx
blob62818dc4ebc362ef3450c9ece7e064fb6d527cdd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLIDESORTERCONTROLLER_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLIDESORTERCONTROLLER_HXX
23 #include "model/SlsSharedPageDescriptor.hxx"
24 #include "ViewShell.hxx"
26 #include <com/sun/star/drawing/XDrawPages.hpp>
28 #include <sfx2/shell.hxx>
29 #include <sfx2/viewfac.hxx>
30 #include <tools/link.hxx>
31 #include <tools/gen.hxx>
33 namespace sd { namespace slidesorter {
34 class SlideSorter;
35 } }
37 namespace sd { namespace slidesorter { namespace view {
38 class SlideSorterView;
39 } } }
41 namespace sd { namespace slidesorter { namespace model {
42 class SlideSorterModel;
43 } } }
45 namespace sd { namespace slidesorter { namespace controller {
47 class Animator;
48 class Clipboard;
49 class CurrentSlideManager;
50 class FocusManager;
51 class InsertionIndicatorHandler;
52 class Listener;
53 class PageSelector;
54 class ScrollBarManager;
55 class SelectionFunction;
56 class SelectionManager;
57 class SlotManager;
58 class VisibleAreaManager;
60 class SlideSorterController
62 public:
63 /** Create a new controller for the slide sorter.
64 @param pParentWindow
65 The window that contains the controls of the new
66 controller.
68 SlideSorterController (SlideSorter& rSlideSorter);
70 /** Late initialization. Call this method once a new new object has been
71 created.
73 void Init();
75 virtual ~SlideSorterController();
77 void Dispose();
79 /** Place and size the scroll bars and the browser window so that the
80 given rectangle is filled.
81 @return
82 The space occupied by the browser window is returned.
84 Rectangle Resize (const Rectangle& rAvailableSpace);
86 /** Determine which of the UI elements--the scroll bars, the scroll bar
87 filler, the actual slide sorter view--are visible and place them in
88 the area last passed to Resize().
89 @param bForce
90 When <TRUE/> is given (<FALSE/> is the default) then the content
91 window and with it the SlideSorterView is resized event when its
92 size does not change (the size does change when the visibility
93 of scroll bars changes.)
94 @return
95 Returns the space occupied by the browser window.
97 Rectangle Rearrange (bool bForce = false);
99 /** Return the descriptor of the page that is rendered under the
100 given position. This takes the IsOnlyPreviewTriggersMouseOver
101 property into account.
102 @return
103 Returns a pointer to a page descriptor instead of a
104 reference because when no page is found at the position
105 then NULL is returned to indicate this.
107 model::SharedPageDescriptor GetPageAt (const Point& rPixelPosition);
109 PageSelector& GetPageSelector();
110 FocusManager& GetFocusManager();
111 controller::Clipboard& GetClipboard();
113 /** Return the object that manages the scroll bars.
115 ScrollBarManager& GetScrollBarManager();
117 ::boost::shared_ptr<CurrentSlideManager> GetCurrentSlideManager() const;
118 ::boost::shared_ptr<SlotManager> GetSlotManager() const;
119 ::boost::shared_ptr<SelectionManager> GetSelectionManager() const;
120 ::boost::shared_ptr<InsertionIndicatorHandler> GetInsertionIndicatorHandler() const;
122 /** This method forwards the call to the SlideSorterView and executes
123 pending operations like moving selected pages into the visible area.
125 void Paint (const Rectangle& rRect, vcl::Window* pWin);
127 void FuTemporary (SfxRequest& rRequest);
128 void FuPermanent (SfxRequest& rRequest);
129 void FuSupport (SfxRequest& rRequest);
130 bool Command (
131 const CommandEvent& rEvent,
132 ::sd::Window* pWindow);
134 void GetCtrlState (SfxItemSet &rSet);
135 void GetStatusBarState (SfxItemSet& rSet);
137 void ExecCtrl (SfxRequest& rRequest);
138 void GetAttrState (SfxItemSet& rSet);
140 bool IsLocked() const;
142 /** Create an object of this inner class to prevent updates due to model
143 changes.
145 class ModelChangeLock
146 {public:
147 ModelChangeLock (SlideSorterController& rController);
148 ~ModelChangeLock();
149 void Release();
150 private:
151 SlideSorterController* mpController;
153 friend class ModelChangeLock;
155 /** Handle a change of the model, that is, handle the removal and
156 insertion of whole pages or a change of the edit mode.
158 This method is a convenience function that simply calls
159 PreModelChange() and then PostModelChange().
161 void HandleModelChange();
163 DECL_LINK(WindowEventHandler, VclWindowEvent*);
165 /** Update the display of all pages. This involves a redraw and
166 releasing previews and caches.
168 void UpdateAllPages();
170 /** This factory method creates a selection function.
172 rtl::Reference<FuPoor> CreateSelectionFunction (SfxRequest& rRequest);
174 /** When the current function of the view shell is the slide sorter
175 selection function then return a reference to it. Otherwise return
176 an empty reference.
178 ::rtl::Reference<SelectionFunction> GetCurrentSelectionFunction();
180 /** Prepare for a change of the edit mode. Depending on the current
181 edit mode we may save the selection so that it can be restored when
182 later changing back to the current edit mode.
184 void PrepareEditModeChange();
186 /** Set a new edit mode and return whether the edit mode really
187 has been changed. For proper saving and restoring of the selection
188 this method should be called between calls to
189 PrepareEditModeChange() and FinishEditModeChange().
190 @return
191 A return value of <TRUE/> indicates that the edit mode has
192 changed.
194 bool ChangeEditMode (EditMode eEditMode);
196 /** Finish the change of the edit mode. Here we may select a page or
197 restore a previously saved selection.
199 void FinishEditModeChange();
201 /** Call this method when the name of one of the pages has changed.
202 This is then notified to the accessibility object, when that exists.
203 @param nPageIndex
204 The index of the page whose name has been changed.
205 @param rsOldName
206 The old name of the page. The new name can be taken from the
207 page object.
209 void PageNameHasChanged (int nPageIndex, const OUString& rsOldName);
211 /** Provide the set of pages to be displayed in the slide sorter. The
212 GetDocumentSlides() method can be found only in the SlideSorterModel.
214 void SetDocumentSlides (const css::uno::Reference<css::container::XIndexAccess>& rxSlides);
216 /** Return an Animator object.
218 ::boost::shared_ptr<Animator> GetAnimator() const { return mpAnimator;}
220 VisibleAreaManager& GetVisibleAreaManager() const;
222 void CheckForMasterPageAssignment();
223 void CheckForSlideTransitionAssignment();
225 private:
226 SlideSorter& mrSlideSorter;
227 model::SlideSorterModel& mrModel;
228 view::SlideSorterView& mrView;
229 ::boost::scoped_ptr<PageSelector> mpPageSelector;
230 ::boost::scoped_ptr<FocusManager> mpFocusManager;
231 ::boost::shared_ptr<SlotManager> mpSlotManager;
232 ::boost::scoped_ptr<ScrollBarManager> mpScrollBarManager;
233 mutable ::boost::shared_ptr<CurrentSlideManager> mpCurrentSlideManager;
234 ::boost::shared_ptr<SelectionManager> mpSelectionManager;
235 ::boost::scoped_ptr<controller::Clipboard> mpClipboard;
236 ::boost::shared_ptr<InsertionIndicatorHandler> mpInsertionIndicatorHandler;
237 ::boost::shared_ptr<Animator> mpAnimator;
238 ::boost::scoped_ptr<VisibleAreaManager> mpVisibleAreaManager;
240 // The listener listens to UNO events and thus is a UNO object.
241 ::rtl::Reference<controller::Listener> mpListener;
243 int mnModelChangeLockCount;
244 bool mbIsForcedRearrangePending;
246 bool mbPreModelChangeDone;
247 bool mbPostModelChangePending;
249 ::std::vector<Link<>> maSelectionChangeListeners;
251 /** This array stores the indices of the selected page descriptors at
252 the time when the edit mode is switched to EM_MASTERPAGE. With this
253 we can restore the selection when switching back to EM_PAGE mode.
255 ::std::vector<SdPage*> maSelectionBeforeSwitch;
256 /// The current page before the edit mode is switched to EM_MASTERPAGE.
257 int mnCurrentPageBeforeSwitch;
259 /** The master page to select after the edit mode is changed. This
260 member is used to pass the pointer from PrepareEditModeChange() to
261 FinishEditModeChange().
263 SdPage* mpEditModeChangeMasterPage;
265 /** This rectangle in the parent window encloses scroll bars and slide
266 sorter window. It is set when Resize() is called.
268 Rectangle maTotalWindowArea;
270 /** This counter is used to avoid processing of reentrant calls to
271 Paint().
273 sal_Int32 mnPaintEntranceCount;
275 /** Remember whether the context menu is open.
277 bool mbIsContextMenuOpen;
279 /** Delete the given list of normal pages. This method is a helper
280 function for DeleteSelectedPages().
281 @param rSelectedNormalPages
282 A list of normal pages. Supplying master pages is an error.
284 void DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedNormalPages);
286 /** Delete the given list of master pages. This method is a helper
287 function for DeleteSelectedPages().
288 @param rSelectedMasterPages
289 A list of master pages. Supplying normal pages is an error.
291 void DeleteSelectedMasterPages (const ::std::vector<SdPage*>& rSelectedMasterPages);
293 /** Prepare for several model changes, i.e. prevent time-consuming and
294 non-critical operations like repaints until UnlockModelChange() is
295 called. Ciritcal operations like releasing references to pages that
296 do not exist anymore are executed.
298 void LockModelChange();
300 /** Further calls to HandleModelChange() will result in a full featured
301 update of model, view, and controller. When HandleModelChange() has
302 been called since the last LockModelChange() then this is done right
303 away to bring the view up-to-date.
305 void UnlockModelChange();
307 /** Prepare for a model change. This method does all the things that
308 need to be done _before_ the model changes, e.g. because they need
309 access to the model data before the change.
311 void PreModelChange();
313 /** Complete a model change. This includes the recreation of data
314 structures that depend on the model and the request for a repaint to
315 show the changes.
317 void PostModelChange();
320 } } } // end of namespace ::sd::slidesorter::controller
322 #endif
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */