1c45d927aSAndrew Rist /************************************************************** 2*916729d0Smseidel * 3c45d927aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4c45d927aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5c45d927aSAndrew Rist * distributed with this work for additional information 6c45d927aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7c45d927aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8c45d927aSAndrew Rist * "License"); you may not use this file except in compliance 9c45d927aSAndrew Rist * with the License. You may obtain a copy of the License at 10*916729d0Smseidel * 11c45d927aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*916729d0Smseidel * 13c45d927aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14c45d927aSAndrew Rist * software distributed under the License is distributed on an 15c45d927aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16c45d927aSAndrew Rist * KIND, either express or implied. See the License for the 17c45d927aSAndrew Rist * specific language governing permissions and limitations 18c45d927aSAndrew Rist * under the License. 19*916729d0Smseidel * 20c45d927aSAndrew Rist *************************************************************/ 21c45d927aSAndrew Rist 22c45d927aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SD_SLIDESORTER_CONTROLLER_SELECTION_MANAGER_HXX 25cdf0e10cSrcweir #define SD_SLIDESORTER_CONTROLLER_SELECTION_MANAGER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "model/SlsSharedPageDescriptor.hxx" 28cdf0e10cSrcweir #include "controller/SlsAnimator.hxx" 29cdf0e10cSrcweir #include <sal/types.h> 30cdf0e10cSrcweir #include <tools/gen.hxx> 31cdf0e10cSrcweir #include <basegfx/range/b2irectangle.hxx> 32cdf0e10cSrcweir #include <vector> 33cdf0e10cSrcweir 34cdf0e10cSrcweir class Link; 35cdf0e10cSrcweir class SdPage; 36cdf0e10cSrcweir 37cdf0e10cSrcweir namespace sd { namespace slidesorter { 38cdf0e10cSrcweir class SlideSorter; 39cdf0e10cSrcweir } } 40cdf0e10cSrcweir 41cdf0e10cSrcweir namespace sd { namespace slidesorter { namespace controller { 42cdf0e10cSrcweir 43cdf0e10cSrcweir class SlideSorterController; 44cdf0e10cSrcweir class SelectionObserver; 45cdf0e10cSrcweir 46cdf0e10cSrcweir /** This class is a part of the controller and handles the selection of 47cdf0e10cSrcweir slides. 48cdf0e10cSrcweir <p>It has methods to modify the selected slides (delete them or 49cdf0e10cSrcweir move them to other places in the document), change the visible area so 50c47da6eaSmseidel to make the selected slides visible, tell listeners when the selection 51cdf0e10cSrcweir changes.</p> 52cdf0e10cSrcweir */ 53cdf0e10cSrcweir class SelectionManager 54cdf0e10cSrcweir { 55cdf0e10cSrcweir public: 56cdf0e10cSrcweir /** Create a new SelectionManger for the given slide sorter. 57cdf0e10cSrcweir */ 58cdf0e10cSrcweir SelectionManager (SlideSorter& rSlideSorter); 59*916729d0Smseidel 60cdf0e10cSrcweir ~SelectionManager (void); 61cdf0e10cSrcweir 62cdf0e10cSrcweir /** Delete the currently selected slides. When this method returns the 63cdf0e10cSrcweir selection is empty. 64cdf0e10cSrcweir @param bSelectFollowingPage 65cdf0e10cSrcweir When <TRUE/> then after deleting the selected pages make the 66cdf0e10cSrcweir slide after the last selected page the new current page. 67cdf0e10cSrcweir When <FALSE/> then make the first slide before the selected 68cdf0e10cSrcweir pages the new current slide. 69cdf0e10cSrcweir */ 70cdf0e10cSrcweir void DeleteSelectedPages (const bool bSelectFollowingPage = true); 71cdf0e10cSrcweir 72cdf0e10cSrcweir /** Call this method after the selection has changed (possible several 73cdf0e10cSrcweir calls to the PageSelector) to invalidate the relevant slots and send 74cdf0e10cSrcweir appropriate events. 75cdf0e10cSrcweir */ 76cdf0e10cSrcweir void SelectionHasChanged (const bool bMakeSelectionVisible = true); 77cdf0e10cSrcweir 78cdf0e10cSrcweir /** Add a listener that is called when the selection of the slide sorter 79cdf0e10cSrcweir changes. 80cdf0e10cSrcweir @param rListener 81cdf0e10cSrcweir When this method is called multiple times for the same listener 82cdf0e10cSrcweir the second and all following calls are ignored. Each listener 83cdf0e10cSrcweir is added only once. 84cdf0e10cSrcweir */ 85cdf0e10cSrcweir void AddSelectionChangeListener (const Link& rListener); 86cdf0e10cSrcweir 87cdf0e10cSrcweir /** Remove a listener that was called when the selection of the slide 88cdf0e10cSrcweir sorter changes. 89cdf0e10cSrcweir @param rListener 90cdf0e10cSrcweir It is save to pass a listener that was not added are has been 91cdf0e10cSrcweir removed previously. Such calls are ignored. 92cdf0e10cSrcweir */ 93cdf0e10cSrcweir void RemoveSelectionChangeListener (const Link& rListener); 94cdf0e10cSrcweir 95cdf0e10cSrcweir /** Return the position where to insert pasted slides based on the 96cdf0e10cSrcweir current selection. When there is a selection then the insert 97cdf0e10cSrcweir position is behind the last slide. When the selection is empty then 98cdf0e10cSrcweir most of the time the insert position is at the end of the document. 99cdf0e10cSrcweir There is an exception right after the display of a popup-menu. The 100cdf0e10cSrcweir position of the associated insertion marker is stored here and reset 101cdf0e10cSrcweir the next time the selection changes. 102cdf0e10cSrcweir */ 103cdf0e10cSrcweir sal_Int32 GetInsertionPosition (void) const; 104cdf0e10cSrcweir 105cdf0e10cSrcweir /** Store an insertion position temporarily. It is reset when the 106cdf0e10cSrcweir selection changes the next time. 107cdf0e10cSrcweir */ 108cdf0e10cSrcweir void SetInsertionPosition (const sal_Int32 nInsertionPosition); 109cdf0e10cSrcweir 110cdf0e10cSrcweir ::boost::shared_ptr<SelectionObserver> GetSelectionObserver (void) const; 111cdf0e10cSrcweir 112cdf0e10cSrcweir private: 113cdf0e10cSrcweir SlideSorter& mrSlideSorter; 114cdf0e10cSrcweir SlideSorterController& mrController; 115cdf0e10cSrcweir 116cdf0e10cSrcweir ::std::vector<Link> maSelectionChangeListeners; 117cdf0e10cSrcweir 118cdf0e10cSrcweir /** This array stores the indices of the selected page descriptors at 119cdf0e10cSrcweir the time when the edit mode is switched to EM_MASTERPAGE. With this 120cdf0e10cSrcweir we can restore the selection when switching back to EM_PAGE mode. 121cdf0e10cSrcweir */ 122cdf0e10cSrcweir ::std::vector<SdPage*> maSelectionBeforeSwitch; 123cdf0e10cSrcweir 124cdf0e10cSrcweir /** When this flag is set then on the next call to Paint() the selection 125cdf0e10cSrcweir is moved into the visible area. 126cdf0e10cSrcweir */ 127cdf0e10cSrcweir bool mbIsMakeSelectionVisiblePending; 128cdf0e10cSrcweir 129cdf0e10cSrcweir /** The insertion position is only temporarily valid. Negative values 130cdf0e10cSrcweir indicate that the explicit insertion position is not valid. In this 131cdf0e10cSrcweir case GetInsertionPosition() calculates it from the current selection. 132cdf0e10cSrcweir */ 133cdf0e10cSrcweir sal_Int32 mnInsertionPosition; 134cdf0e10cSrcweir 135cdf0e10cSrcweir /** Animation id for a scroll animation the will eventually set the top 136cdf0e10cSrcweir and left of the visible area to maRequestedTopLeft. 137cdf0e10cSrcweir */ 138cdf0e10cSrcweir Animator::AnimationId mnAnimationId; 139cdf0e10cSrcweir Point maRequestedTopLeft; 140cdf0e10cSrcweir 141cdf0e10cSrcweir class PageInsertionListener; 142cdf0e10cSrcweir ::boost::scoped_ptr<PageInsertionListener> mpPageInsertionListener; 143cdf0e10cSrcweir 144cdf0e10cSrcweir ::boost::shared_ptr<SelectionObserver> mpSelectionObserver; 145cdf0e10cSrcweir 146cdf0e10cSrcweir /** Delete the given list of normal pages. This method is a helper 147cdf0e10cSrcweir function for DeleteSelectedPages(). 148cdf0e10cSrcweir @param rSelectedNormalPages 149cdf0e10cSrcweir A list of normal pages. Supplying master pages is an error. 150cdf0e10cSrcweir */ 151cdf0e10cSrcweir void DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedNormalPages); 152cdf0e10cSrcweir 153cdf0e10cSrcweir /** Delete the given list of master pages. This method is a helper 154cdf0e10cSrcweir function for DeleteSelectedPages(). 155cdf0e10cSrcweir @param rSelectedMasterPages 156cdf0e10cSrcweir A list of master pages. Supplying normal pages is an error. 157cdf0e10cSrcweir */ 158cdf0e10cSrcweir void DeleteSelectedMasterPages (const ::std::vector<SdPage*>& rSelectedMasterPages); 159cdf0e10cSrcweir }; 160cdf0e10cSrcweir 161cdf0e10cSrcweir } } } // end of namespace ::sd::slidesorter::controller 162cdf0e10cSrcweir 163cdf0e10cSrcweir #endif 164