bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / slidesorter / inc / controller / SlsSelectionManager.hxx
blob84a95942c0f073cec73614c6122b20118753bd25
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_SLSSELECTIONMANAGER_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSSELECTIONMANAGER_HXX
23 #include "model/SlsSharedPageDescriptor.hxx"
24 #include "controller/SlsAnimator.hxx"
25 #include <sal/types.h>
26 #include <tools/gen.hxx>
27 #include <tools/link.hxx>
28 #include <basegfx/range/b2irectangle.hxx>
29 #include <vector>
31 class SdPage;
33 namespace sd { namespace slidesorter {
34 class SlideSorter;
35 } }
37 namespace sd { namespace slidesorter { namespace controller {
39 class SlideSorterController;
40 class SelectionObserver;
42 /** This class is a part of the controller and handles the selection of
43 slides.
44 <p>It has methods to modify the selected slides (delete them or
45 move them to other places in the document), change the visible area so
46 to make the selected slides visble, tell listeners when the selection
47 changes.</p>
49 class SelectionManager
51 public:
52 /** Create a new SelectionManger for the given slide sorter.
54 SelectionManager (SlideSorter& rSlideSorter);
56 ~SelectionManager();
58 /** Delete the currently selected slides. When this method returns the
59 selection is empty.
60 @param bSelectFollowingPage
61 When <TRUE/> then after deleting the selected pages make the
62 slide after the last selected page the new current page.
63 When <FALSE/> then make the first slide before the selected
64 pages the new current slide.
66 void DeleteSelectedPages (const bool bSelectFollowingPage = true);
68 /** Call this method after the selection has changed (possible several
69 calls to the PageSelector) to invalidate the relevant slots and send
70 appropriate events.
72 void SelectionHasChanged (const bool bMakeSelectionVisible = true);
74 /** Add a listener that is called when the selection of the slide sorter
75 changes.
76 @param rListener
77 When this method is called multiple times for the same listener
78 the second and all following calls are ignored. Each listener
79 is added only once.
81 void AddSelectionChangeListener (const Link<>& rListener);
83 /** Remove a listener that was called when the selection of the slide
84 sorter changes.
85 @param rListener
86 It is save to pass a listener that was not added are has been
87 removed previously. Such calls are ignored.
89 void RemoveSelectionChangeListener (const Link<>& rListener);
91 /** Return the position where to insert pasted slides based on the
92 current selection. When there is a selection then the insert
93 position is behind the last slide. When the selection is empty then
94 most of the time the insert position is at the end of the document.
95 There is an exception right after the display of a popup-menu. The
96 position of the associated insertion marker is stored here and reset
97 the next time the selection changes.
99 sal_Int32 GetInsertionPosition() const;
101 /** Store an insertion position temporarily. It is reset when the
102 selection changes the next time.
104 void SetInsertionPosition (const sal_Int32 nInsertionPosition);
106 ::boost::shared_ptr<SelectionObserver> GetSelectionObserver() const { return mpSelectionObserver;}
108 private:
109 SlideSorter& mrSlideSorter;
110 SlideSorterController& mrController;
112 ::std::vector<Link<>> maSelectionChangeListeners;
114 /** This array stores the indices of the selected page descriptors at
115 the time when the edit mode is switched to EM_MASTERPAGE. With this
116 we can restore the selection when switching back to EM_PAGE mode.
118 ::std::vector<SdPage*> maSelectionBeforeSwitch;
120 /** When this flag is set then on the next call to Paint() the selection
121 is moved into the visible area.
123 bool mbIsMakeSelectionVisiblePending;
125 /** The insertion position is only temporarily valid. Negative values
126 indicate that the explicit insertion position is not valid. In this
127 case GetInsertionPosition() calculates it from the current selection.
129 sal_Int32 mnInsertionPosition;
131 /** Animation id for a scroll animation the will eventually set the top
132 and left of the visible area to maRequestedTopLeft.
134 Animator::AnimationId mnAnimationId;
136 class PageInsertionListener;
137 ::boost::scoped_ptr<PageInsertionListener> mpPageInsertionListener;
139 ::boost::shared_ptr<SelectionObserver> mpSelectionObserver;
141 /** Delete the given list of normal pages. This method is a helper
142 function for DeleteSelectedPages().
143 @param rSelectedNormalPages
144 A list of normal pages. Supplying master pages is an error.
146 void DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedNormalPages);
148 /** Delete the given list of master pages. This method is a helper
149 function for DeleteSelectedPages().
150 @param rSelectedMasterPages
151 A list of master pages. Supplying normal pages is an error.
153 void DeleteSelectedMasterPages (const ::std::vector<SdPage*>& rSelectedMasterPages);
156 } } } // end of namespace ::sd::slidesorter::controller
158 #endif
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */