Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLIDESORTERCONTROLLER_HXX
21 : #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLIDESORTERCONTROLLER_HXX
22 :
23 : #include "model/SlsSharedPageDescriptor.hxx"
24 : #include "ViewShell.hxx"
25 :
26 : #include <com/sun/star/drawing/XDrawPages.hpp>
27 :
28 : #include <sfx2/shell.hxx>
29 : #include <sfx2/viewfac.hxx>
30 : #include <tools/link.hxx>
31 : #include <tools/gen.hxx>
32 :
33 : namespace sd { namespace slidesorter {
34 : class SlideSorter;
35 : } }
36 :
37 : namespace sd { namespace slidesorter { namespace view {
38 : class SlideSorterView;
39 : } } }
40 :
41 : namespace sd { namespace slidesorter { namespace model {
42 : class SlideSorterModel;
43 : } } }
44 :
45 : namespace sd { namespace slidesorter { namespace controller {
46 :
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;
59 :
60 : class SlideSorterController
61 : {
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.
67 : */
68 : SlideSorterController (SlideSorter& rSlideSorter);
69 :
70 : /** Late initialization. Call this method once a new new object has been
71 : created.
72 : */
73 : virtual void Init (void);
74 :
75 : virtual ~SlideSorterController (void);
76 :
77 : void Dispose (void);
78 :
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.
83 : */
84 : Rectangle Resize (const Rectangle& rAvailableSpace);
85 :
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.
96 : */
97 : Rectangle Rearrange (bool bForce = false);
98 :
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.
106 : */
107 : model::SharedPageDescriptor GetPageAt (const Point& rPixelPosition);
108 :
109 : PageSelector& GetPageSelector (void);
110 : FocusManager& GetFocusManager (void);
111 : controller::Clipboard& GetClipboard (void);
112 :
113 : /** Return the object that manages the scroll bars.
114 : */
115 : ScrollBarManager& GetScrollBarManager (void);
116 :
117 : ::boost::shared_ptr<CurrentSlideManager> GetCurrentSlideManager (void) const;
118 : ::boost::shared_ptr<SlotManager> GetSlotManager (void) const;
119 : ::boost::shared_ptr<SelectionManager> GetSelectionManager (void) const;
120 : ::boost::shared_ptr<InsertionIndicatorHandler> GetInsertionIndicatorHandler (void) const;
121 :
122 : /** This method forwards the call to the SlideSorterView and executes
123 : pending operations like moving selected pages into the visible area.
124 : */
125 : void Paint (const Rectangle& rRect, vcl::Window* pWin);
126 :
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);
133 :
134 : void GetCtrlState (SfxItemSet &rSet);
135 : void GetStatusBarState (SfxItemSet& rSet);
136 :
137 : void ExecCtrl (SfxRequest& rRequest);
138 : void GetAttrState (SfxItemSet& rSet);
139 : void ExecStatusBar (SfxRequest& rRequest);
140 :
141 : bool IsLocked (void) const;
142 :
143 : /** Create an object of this inner class to prevent updates due to model
144 : changes.
145 : */
146 : class ModelChangeLock
147 : {public:
148 : ModelChangeLock (SlideSorterController& rController);
149 : ~ModelChangeLock (void);
150 : void Release (void);
151 : private:
152 : SlideSorterController* mpController;
153 : };
154 : friend class ModelChangeLock;
155 :
156 : /** Handle a change of the model, that is, handle the removal and
157 : insertion of whole pages or a change of the edit mode.
158 :
159 : This method is a convenience function that simply calls
160 : PreModelChange() and then PostModelChange().
161 : */
162 : void HandleModelChange (void);
163 :
164 : DECL_LINK(WindowEventHandler, VclWindowEvent*);
165 :
166 : /** Update the display of all pages. This involves a redraw and
167 : releasing previews and caches.
168 : */
169 : void UpdateAllPages (void);
170 :
171 : /** This factory method creates a selection function.
172 : */
173 : virtual rtl::Reference<FuPoor> CreateSelectionFunction (SfxRequest& rRequest);
174 :
175 : /** When the current function of the view shell is the slide sorter
176 : selection function then return a reference to it. Otherwise return
177 : an empty reference.
178 : */
179 : ::rtl::Reference<SelectionFunction> GetCurrentSelectionFunction (void);
180 :
181 : /** Prepare for a change of the edit mode. Depending on the current
182 : edit mode we may save the selection so that it can be restored when
183 : later changing back to the current edit mode.
184 : */
185 : void PrepareEditModeChange (void);
186 :
187 : /** Set a new edit mode and return whether the edit mode really
188 : has been changed. For proper saving and restoring of the selection
189 : this method should be called between calls to
190 : PrepareEditModeChange() and FinishEditModeChange().
191 : @return
192 : A return value of <TRUE/> indicates that the edit mode has
193 : changed.
194 : */
195 : bool ChangeEditMode (EditMode eEditMode);
196 :
197 : /** Finish the change of the edit mode. Here we may select a page or
198 : restore a previously saved selection.
199 : */
200 : void FinishEditModeChange (void);
201 :
202 : /** Call this method when the name of one of the pages has changed.
203 : This is then notified to the accessibility object, when that exists.
204 : @param nPageIndex
205 : The index of the page whose name has been changed.
206 : @param rsOldName
207 : The old name of the page. The new name can be taken from the
208 : page object.
209 : */
210 : void PageNameHasChanged (int nPageIndex, const OUString& rsOldName);
211 :
212 : /** Provide the set of pages to be displayed in the slide sorter. The
213 : GetDocumentSlides() method can be found only in the SlideSorterModel.
214 : */
215 : void SetDocumentSlides (const css::uno::Reference<css::container::XIndexAccess>& rxSlides);
216 :
217 : /** Return an Animator object.
218 : */
219 126 : ::boost::shared_ptr<Animator> GetAnimator (void) const { return mpAnimator;}
220 :
221 : VisibleAreaManager& GetVisibleAreaManager (void) const;
222 :
223 : void CheckForMasterPageAssignment (void);
224 : void CheckForSlideTransitionAssignment (void);
225 :
226 : private:
227 : SlideSorter& mrSlideSorter;
228 : model::SlideSorterModel& mrModel;
229 : view::SlideSorterView& mrView;
230 : ::boost::scoped_ptr<PageSelector> mpPageSelector;
231 : ::boost::scoped_ptr<FocusManager> mpFocusManager;
232 : ::boost::shared_ptr<SlotManager> mpSlotManager;
233 : ::boost::scoped_ptr<ScrollBarManager> mpScrollBarManager;
234 : mutable ::boost::shared_ptr<CurrentSlideManager> mpCurrentSlideManager;
235 : ::boost::shared_ptr<SelectionManager> mpSelectionManager;
236 : ::boost::scoped_ptr<controller::Clipboard> mpClipboard;
237 : ::boost::shared_ptr<InsertionIndicatorHandler> mpInsertionIndicatorHandler;
238 : ::boost::shared_ptr<Animator> mpAnimator;
239 : ::boost::scoped_ptr<VisibleAreaManager> mpVisibleAreaManager;
240 :
241 : // The listener listens to UNO events and thus is a UNO object.
242 : ::rtl::Reference<controller::Listener> mpListener;
243 :
244 : int mnModelChangeLockCount;
245 : bool mbIsForcedRearrangePending;
246 :
247 : bool mbPreModelChangeDone;
248 : bool mbPostModelChangePending;
249 :
250 : ::std::vector<Link> maSelectionChangeListeners;
251 :
252 : /** This array stores the indices of the selected page descriptors at
253 : the time when the edit mode is switched to EM_MASTERPAGE. With this
254 : we can restore the selection when switching back to EM_PAGE mode.
255 : */
256 : ::std::vector<SdPage*> maSelectionBeforeSwitch;
257 : /// The current page before the edit mode is switched to EM_MASTERPAGE.
258 : int mnCurrentPageBeforeSwitch;
259 :
260 : /** The master page to select after the edit mode is changed. This
261 : member is used to pass the pointer from PrepareEditModeChange() to
262 : FinishEditModeChange().
263 : */
264 : SdPage* mpEditModeChangeMasterPage;
265 :
266 : /** This rectangle in the parent window encloses scroll bars and slide
267 : sorter window. It is set when Resize() is called.
268 : */
269 : Rectangle maTotalWindowArea;
270 :
271 : /** This counter is used to avoid processing of reentrant calls to
272 : Paint().
273 : */
274 : sal_Int32 mnPaintEntranceCount;
275 :
276 : /** Remember whether the context menu is open.
277 : */
278 : bool mbIsContextMenuOpen;
279 :
280 : /** Delete the given list of normal pages. This method is a helper
281 : function for DeleteSelectedPages().
282 : @param rSelectedNormalPages
283 : A list of normal pages. Supplying master pages is an error.
284 : */
285 : void DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedNormalPages);
286 :
287 : /** Delete the given list of master pages. This method is a helper
288 : function for DeleteSelectedPages().
289 : @param rSelectedMasterPages
290 : A list of master pages. Supplying normal pages is an error.
291 : */
292 : void DeleteSelectedMasterPages (const ::std::vector<SdPage*>& rSelectedMasterPages);
293 :
294 : /** Prepare for several model changes, i.e. prevent time-consuming and
295 : non-critical operations like repaints until UnlockModelChange() is
296 : called. Ciritcal operations like releasing references to pages that
297 : do not exist anymore are executed.
298 : */
299 : void LockModelChange (void);
300 :
301 : /** Further calls to HandleModelChange() will result in a full featured
302 : update of model, view, and controller. When HandleModelChange() has
303 : been called since the last LockModelChange() then this is done right
304 : away to bring the view up-to-date.
305 : */
306 : void UnlockModelChange (void);
307 :
308 : /** Prepare for a model change. This method does all the things that
309 : need to be done _before_ the model changes, e.g. because they need
310 : access to the model data before the change.
311 : */
312 : void PreModelChange (void);
313 :
314 : /** Complete a model change. This includes the recreation of data
315 : structures that depend on the model and the request for a repaint to
316 : show the changes.
317 : */
318 : void PostModelChange (void);
319 : };
320 :
321 : } } } // end of namespace ::sd::slidesorter::controller
322 :
323 : #endif
324 :
325 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|