bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / slidesorter / inc / controller / SlideSorterController.hxx
blobbd23def8abd5997b3dc5663ec376ed2c841ed083
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 <pres.hxx>
26 #include <tools/link.hxx>
27 #include <tools/gen.hxx>
28 #include <rtl/ref.hxx>
29 #include <rtl/ustring.hxx>
31 #include <sddllapi.h>
33 #include <memory>
34 #include <vector>
36 namespace com { namespace sun { namespace star { namespace container { class XIndexAccess; } } } }
37 namespace com { namespace sun { namespace star { namespace uno { template <typename > class Reference; } } } }
38 namespace sd { class FuPoor; }
39 namespace sd { class Window; }
40 namespace vcl { class Window; }
42 namespace sd { namespace slidesorter {
43 class SlideSorter;
44 } }
46 namespace sd { namespace slidesorter { namespace view {
47 class SlideSorterView;
48 } } }
50 namespace sd { namespace slidesorter { namespace model {
51 class SlideSorterModel;
52 } } }
54 class CommandEvent;
55 class SdPage;
56 class SfxItemSet;
57 class SfxRequest;
58 class VclSimpleEvent;
59 class VclWindowEvent;
61 namespace sd { namespace slidesorter { namespace controller {
63 class Animator;
64 class Clipboard;
65 class CurrentSlideManager;
66 class FocusManager;
67 class InsertionIndicatorHandler;
68 class Listener;
69 class PageSelector;
70 class ScrollBarManager;
71 class SelectionFunction;
72 class SelectionManager;
73 class SlotManager;
74 class VisibleAreaManager;
76 class SlideSorterController final
78 public:
79 /** Create a new controller for the slide sorter.
80 @param pParentWindow
81 The window that contains the controls of the new
82 controller.
84 SlideSorterController (SlideSorter& rSlideSorter);
86 /** Late initialization. Call this method once a new object has been
87 created.
89 void Init();
91 ~SlideSorterController();
93 void Dispose();
95 /** Place and size the scroll bars and the browser window so that the
96 given rectangle is filled.
98 void Resize (const ::tools::Rectangle& rAvailableSpace);
100 /** Determine which of the UI elements--the scroll bars, the scroll bar
101 filler, the actual slide sorter view--are visible and place them in
102 the area last passed to Resize().
103 @param bForce
104 When <TRUE/> is given (<FALSE/> is the default) then the content
105 window and with it the SlideSorterView is resized event when its
106 size does not change (the size does change when the visibility
107 of scroll bars changes.)
109 void Rearrange (bool bForce);
111 /** Return the descriptor of the page that is rendered under the
112 given position. This takes the IsOnlyPreviewTriggersMouseOver
113 property into account.
114 @return
115 Returns a pointer to a page descriptor instead of a
116 reference because when no page is found at the position
117 then NULL is returned to indicate this.
119 model::SharedPageDescriptor GetPageAt (const Point& rPixelPosition);
121 // Exported for unit test
122 SD_DLLPUBLIC PageSelector& GetPageSelector();
123 FocusManager& GetFocusManager();
124 // Exported for unit test
125 SD_DLLPUBLIC controller::Clipboard& GetClipboard();
127 /** Return the object that manages the scroll bars.
129 ScrollBarManager& GetScrollBarManager();
131 std::shared_ptr<CurrentSlideManager> const & GetCurrentSlideManager() const;
132 std::shared_ptr<SlotManager> const & GetSlotManager() const;
133 std::shared_ptr<SelectionManager> const & GetSelectionManager() const;
134 std::shared_ptr<InsertionIndicatorHandler> const & GetInsertionIndicatorHandler() const;
136 /** This method forwards the call to the SlideSorterView and executes
137 pending operations like moving selected pages into the visible area.
139 void Paint (const ::tools::Rectangle& rRect, vcl::Window* pWin);
141 void FuTemporary (SfxRequest& rRequest);
142 void FuPermanent (SfxRequest& rRequest);
143 void FuSupport (SfxRequest& rRequest);
144 bool Command (
145 const CommandEvent& rEvent,
146 ::sd::Window* pWindow);
148 void GetCtrlState (SfxItemSet &rSet);
149 void GetStatusBarState (SfxItemSet& rSet);
151 void ExecCtrl (SfxRequest& rRequest);
152 void GetAttrState (SfxItemSet& rSet);
154 /** Create an object of this inner class to prevent updates due to model
155 changes.
157 class ModelChangeLock
158 {public:
159 ModelChangeLock (SlideSorterController& rController);
160 ~ModelChangeLock() COVERITY_NOEXCEPT_FALSE;
161 void Release();
162 private:
163 SlideSorterController* mpController;
165 friend class ModelChangeLock;
167 /** Handle a change of the model, that is, handle the removal and
168 insertion of whole pages or a change of the edit mode.
170 This method is a convenience function that simply calls
171 PreModelChange() and then PostModelChange().
173 void HandleModelChange();
175 DECL_LINK(WindowEventHandler, VclWindowEvent&, void);
176 DECL_LINK(ApplicationEventHandler, VclSimpleEvent&, void);
178 /** Update the display of all pages. This involves a redraw and
179 releasing previews and caches.
181 void UpdateAllPages();
183 /** This factory method creates a selection function.
185 rtl::Reference<FuPoor> CreateSelectionFunction (SfxRequest& rRequest);
187 /** When the current function of the view shell is the slide sorter
188 selection function then return a reference to it. Otherwise return
189 an empty reference.
191 ::rtl::Reference<SelectionFunction> GetCurrentSelectionFunction();
193 /** Prepare for a change of the edit mode. Depending on the current
194 edit mode we may save the selection so that it can be restored when
195 later changing back to the current edit mode.
197 void PrepareEditModeChange();
199 /** Set a new edit mode and return whether the edit mode really
200 has been changed. For proper saving and restoring of the selection
201 this method should be called between calls to
202 PrepareEditModeChange() and FinishEditModeChange().
204 void ChangeEditMode (EditMode eEditMode);
206 /** Finish the change of the edit mode. Here we may select a page or
207 restore a previously saved selection.
209 void FinishEditModeChange();
211 /** Call this method when the name of one of the pages has changed.
212 This is then notified to the accessibility object, when that exists.
213 @param nPageIndex
214 The index of the page whose name has been changed.
215 @param rsOldName
216 The old name of the page. The new name can be taken from the
217 page object.
219 void PageNameHasChanged (int nPageIndex, const OUString& rsOldName);
221 /** Provide the set of pages to be displayed in the slide sorter. The
222 GetDocumentSlides() method can be found only in the SlideSorterModel.
224 void SetDocumentSlides (const css::uno::Reference<css::container::XIndexAccess>& rxSlides);
226 /** Return an Animator object.
228 const std::shared_ptr<Animator>& GetAnimator() const { return mpAnimator;}
230 VisibleAreaManager& GetVisibleAreaManager() const;
232 void CheckForMasterPageAssignment();
233 void CheckForSlideTransitionAssignment();
235 private:
236 SlideSorter& mrSlideSorter;
237 model::SlideSorterModel& mrModel;
238 view::SlideSorterView& mrView;
239 std::unique_ptr<PageSelector> mpPageSelector;
240 std::unique_ptr<FocusManager> mpFocusManager;
241 std::shared_ptr<SlotManager> mpSlotManager;
242 std::unique_ptr<ScrollBarManager> mpScrollBarManager;
243 mutable std::shared_ptr<CurrentSlideManager> mpCurrentSlideManager;
244 std::shared_ptr<SelectionManager> mpSelectionManager;
245 std::unique_ptr<controller::Clipboard> mpClipboard;
246 std::shared_ptr<InsertionIndicatorHandler> mpInsertionIndicatorHandler;
247 std::shared_ptr<Animator> mpAnimator;
248 std::unique_ptr<VisibleAreaManager> mpVisibleAreaManager;
250 // The listener listens to UNO events and thus is a UNO object.
251 ::rtl::Reference<controller::Listener> mpListener;
253 int mnModelChangeLockCount;
254 bool mbIsForcedRearrangePending;
255 bool mbContextMenuOpen;
257 bool mbPostModelChangePending;
259 /** This array stores the indices of the selected page descriptors at
260 the time when the edit mode is switched to EditMode::MasterPage. With this
261 we can restore the selection when switching back to EditMode::Page mode.
263 ::std::vector<SdPage*> maSelectionBeforeSwitch;
264 /// The current page before the edit mode is switched to EditMode::MasterPage.
265 int mnCurrentPageBeforeSwitch;
267 /** The master page to select after the edit mode is changed. This
268 member is used to pass the pointer from PrepareEditModeChange() to
269 FinishEditModeChange().
271 SdPage* mpEditModeChangeMasterPage;
273 /** This rectangle in the parent window encloses scroll bars and slide
274 sorter window. It is set when Resize() is called.
276 ::tools::Rectangle maTotalWindowArea;
278 /** This counter is used to avoid processing of reentrant calls to
279 Paint().
281 sal_Int32 mnPaintEntranceCount;
283 /** Prepare for several model changes, i.e. prevent time-consuming and
284 non-critical operations like repaints until UnlockModelChange() is
285 called. Critical operations like releasing references to pages that
286 do not exist anymore are executed.
288 void LockModelChange();
290 /** Further calls to HandleModelChange() will result in a full featured
291 update of model, view, and controller. When HandleModelChange() has
292 been called since the last LockModelChange() then this is done right
293 away to bring the view up-to-date.
295 void UnlockModelChange();
297 /** Prepare for a model change. This method does all the things that
298 need to be done _before_ the model changes, e.g. because they need
299 access to the model data before the change.
301 void PreModelChange();
303 /** Complete a model change. This includes the recreation of data
304 structures that depend on the model and the request for a repaint to
305 show the changes.
307 void PostModelChange();
310 } } } // end of namespace ::sd::slidesorter::controller
312 #endif
314 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */