LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/inc/controller - SlsSelectionManager.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          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_SLSSELECTIONMANAGER_HXX
      21             : #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSSELECTIONMANAGER_HXX
      22             : 
      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>
      30             : 
      31             : class SdPage;
      32             : 
      33             : namespace sd { namespace slidesorter {
      34             : class SlideSorter;
      35             : } }
      36             : 
      37             : namespace sd { namespace slidesorter { namespace controller {
      38             : 
      39             : class SlideSorterController;
      40             : class SelectionObserver;
      41             : 
      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>
      48             : */
      49             : class SelectionManager
      50             : {
      51             : public:
      52             :     /** Create a new SelectionManger for the given slide sorter.
      53             :     */
      54             :     SelectionManager (SlideSorter& rSlideSorter);
      55             : 
      56             :     ~SelectionManager();
      57             : 
      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.
      65             :     */
      66             :     void DeleteSelectedPages (const bool bSelectFollowingPage = true);
      67             : 
      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.
      71             :     */
      72             :     void SelectionHasChanged (const bool bMakeSelectionVisible = true);
      73             : 
      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.
      80             :     */
      81             :     void AddSelectionChangeListener (const Link<>& rListener);
      82             : 
      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.
      88             :     */
      89             :     void RemoveSelectionChangeListener (const Link<>& rListener);
      90             : 
      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.
      98             :     */
      99             :     sal_Int32 GetInsertionPosition() const;
     100             : 
     101             :     /** Store an insertion position temporarily.  It is reset when the
     102             :         selection changes the next time.
     103             :     */
     104             :     void SetInsertionPosition (const sal_Int32 nInsertionPosition);
     105             : 
     106          11 :     ::boost::shared_ptr<SelectionObserver> GetSelectionObserver() const { return mpSelectionObserver;}
     107             : 
     108             : private:
     109             :     SlideSorter& mrSlideSorter;
     110             :     SlideSorterController& mrController;
     111             : 
     112             :     ::std::vector<Link<>> maSelectionChangeListeners;
     113             : 
     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.
     117             :     */
     118             :     ::std::vector<SdPage*> maSelectionBeforeSwitch;
     119             : 
     120             :     /** When this flag is set then on the next call to Paint() the selection
     121             :         is moved into the visible area.
     122             :     */
     123             :     bool mbIsMakeSelectionVisiblePending;
     124             : 
     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.
     128             :     */
     129             :     sal_Int32 mnInsertionPosition;
     130             : 
     131             :     /** Animation id for a scroll animation the will eventually set the top
     132             :         and left of the visible area to maRequestedTopLeft.
     133             :     */
     134             :     Animator::AnimationId mnAnimationId;
     135             : 
     136             :     class PageInsertionListener;
     137             :     ::boost::scoped_ptr<PageInsertionListener> mpPageInsertionListener;
     138             : 
     139             :     ::boost::shared_ptr<SelectionObserver> mpSelectionObserver;
     140             : 
     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.
     145             :     */
     146             :     void DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedNormalPages);
     147             : 
     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.
     152             :     */
     153             :     void DeleteSelectedMasterPages (const ::std::vector<SdPage*>& rSelectedMasterPages);
     154             : };
     155             : 
     156             : } } } // end of namespace ::sd::slidesorter::controller
     157             : 
     158             : #endif
     159             : 
     160             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11