LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/inc/controller - SlsPageSelector.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1 100.0 %
Date: 2012-08-25 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef SD_SLIDESORTER_PAGE_SELECTOR_HXX
      30                 :            : #define SD_SLIDESORTER_PAGE_SELECTOR_HXX
      31                 :            : 
      32                 :            : #include "model/SlsSharedPageDescriptor.hxx"
      33                 :            : 
      34                 :            : #include <com/sun/star/drawing/XDrawPage.hpp>
      35                 :            : #include <vector>
      36                 :            : #include <memory>
      37                 :            : #include <boost/noncopyable.hpp>
      38                 :            : 
      39                 :            : 
      40                 :            : class SdPage;
      41                 :            : 
      42                 :            : namespace sd { namespace slidesorter {
      43                 :            : class SlideSorter;
      44                 :            : } }
      45                 :            : 
      46                 :            : namespace sd { namespace slidesorter { namespace model {
      47                 :            : class SlideSorterModel;
      48                 :            : } } }
      49                 :            : 
      50                 :            : namespace sd { namespace slidesorter { namespace controller {
      51                 :            : 
      52                 :            : class SlideSorterController;
      53                 :            : 
      54                 :            : 
      55                 :            : /** A sub-controller that handles page selection of the slide browser.
      56                 :            :     Selecting a page does not make it the current page (of the main view)
      57                 :            :     automatically as this would not be desired in a multi selection.  This
      58                 :            :     has to be done explicitly by calling the
      59                 :            :     CurrentSlideManager::SetCurrentSlide() method.
      60                 :            : 
      61                 :            :     Indices of pages relate allways to the number of all pages in the model
      62                 :            :     (as returned by GetPageCount()) not just the selected pages.
      63                 :            : */
      64 [ +  - ][ +  - ]:        130 : class PageSelector : private ::boost::noncopyable
                 [ +  - ]
      65                 :            : {
      66                 :            : public:
      67                 :            :     PageSelector (SlideSorter& rSlideSorter);
      68                 :            : 
      69                 :            :     void SelectAllPages (void);
      70                 :            :     void DeselectAllPages (void);
      71                 :            : 
      72                 :            :     /** Update the selection state of all page descriptors to be the same as
      73                 :            :         that of the corresponding pages of the SdPage objects and issue
      74                 :            :         redraw requests where necessary.
      75                 :            :     */
      76                 :            :     void GetCoreSelection (void);
      77                 :            : 
      78                 :            :     /** Update the selection state of the SdPage objects to be the same as
      79                 :            :         that of the correspinding page descriptors.
      80                 :            :     */
      81                 :            :     void SetCoreSelection (void);
      82                 :            : 
      83                 :            :     /** Select the specified descriptor.  The selection state of the other
      84                 :            :         descriptors is not affected.
      85                 :            :     */
      86                 :            :     void SelectPage (int nPageIndex);
      87                 :            :     /** Select the descriptor that is associated with the given page.  The
      88                 :            :         selection state of the other descriptors is not affected.
      89                 :            :     */
      90                 :            :     void SelectPage (const SdPage* pPage);
      91                 :            :     /** Select the specified descriptor.  The selection state of the other
      92                 :            :         descriptors is not affected.
      93                 :            :     */
      94                 :            :     void SelectPage (const model::SharedPageDescriptor& rpDescriptor);
      95                 :            : 
      96                 :            :     /** Return whether the specified page is selected.  This convenience
      97                 :            :         method is a subsitute for
      98                 :            :         SlideSorterModel::GetPageDescriptor(i)->IsSelected() is included
      99                 :            :         here to make this class more self contained.
     100                 :            :     */
     101                 :            :     bool IsPageSelected (int nPageIndex);
     102                 :            : 
     103                 :            :     /** Deselect the descriptor that is associated with the given page.
     104                 :            :         @param bUpdateCurrentPage
     105                 :            :             When <TRUE/> then the current page is updated to the first slide
     106                 :            :             of the remaining selection.
     107                 :            :     */
     108                 :            :     void DeselectPage (
     109                 :            :         int nPageIndex,
     110                 :            :         const bool bUpdateCurrentPage = true);
     111                 :            :     void DeselectPage (
     112                 :            :         const model::SharedPageDescriptor& rpDescriptor,
     113                 :            :         const bool bUpdateCurrentPage = true);
     114                 :            : 
     115                 :            :     /** This convenience method returns the same number of pages that
     116                 :            :         SlideSorterModel.GetPageCount() returns.  It is included here so
     117                 :            :         that it is self contained for iterating over all pages to select or
     118                 :            :         deselect them.
     119                 :            :     */
     120                 :            :     int GetPageCount (void) const;
     121                 :            :     int GetSelectedPageCount (void) const;
     122                 :            : 
     123                 :            :     /** Return the anchor for a range selection.  This usually is the first
     124                 :            :         selected page after all pages have been deselected.
     125                 :            :         @return
     126                 :            :             The returned anchor may be NULL.
     127                 :            :     */
     128                 :            :     model::SharedPageDescriptor GetSelectionAnchor (void) const;
     129                 :            : 
     130                 :            : 
     131                 :            :     typedef ::std::vector<SdPage*> PageSelection;
     132                 :            : 
     133                 :            :     /** Return an object that describes the current selection.  The caller
     134                 :            :         can use that object to later restore the selection.
     135                 :            :         @return
     136                 :            :             The object returned describes the selection via indices.  So
     137                 :            :             even if pages are exchanged a later call to SetPageSelection()
     138                 :            :             is valid.
     139                 :            :     */
     140                 :            :     ::boost::shared_ptr<PageSelection> GetPageSelection (void) const;
     141                 :            : 
     142                 :            :     /** Restore a page selection according to the given selection object.
     143                 :            :         @param rSelection
     144                 :            :             Typically obtained by calling GetPageSelection() this object
     145                 :            :             is used to restore the selection.  If pages were exchanged since
     146                 :            :             the last call to GetPageSelection() it is still valid to call
     147                 :            :             this method with the selection.  When pages have been inserted
     148                 :            :             or removed the result may be unexpected.
     149                 :            :         @param bUpdateCurrentPage
     150                 :            :             When <TRUE/> (the default value) then after setting the
     151                 :            :             selection update the current page to the first page of the
     152                 :            :             selection.
     153                 :            :             When called from withing UpdateCurrentPage() then this flag is
     154                 :            :             used to prevent a recursion loop.
     155                 :            :     */
     156                 :            :     void SetPageSelection (
     157                 :            :         const ::boost::shared_ptr<PageSelection>& rSelection,
     158                 :            :         const bool bUpdateCurrentPage = true);
     159                 :            : 
     160                 :            :     /** Call this method after the the model has changed to set the number
     161                 :            :         of selected pages.
     162                 :            :     */
     163                 :            :     void CountSelectedPages (void);
     164                 :            : 
     165                 :            :     /** Use the UpdateLock whenever you do a complex selection, i.e. call
     166                 :            :         more than one method in a row.  An active lock prevents intermediate
     167                 :            :         changes of the current slide.
     168                 :            :     */
     169                 :            :     class UpdateLock
     170                 :            :     {
     171                 :            :     public:
     172                 :            :         UpdateLock (SlideSorter& rSlideSorter);
     173                 :            :         UpdateLock (PageSelector& rPageSelector);
     174                 :            :         ~UpdateLock (void);
     175                 :            :         void Release (void);
     176                 :            :     private:
     177                 :            :         PageSelector* mpSelector;
     178                 :            :     };
     179                 :            : 
     180                 :            :     class BroadcastLock
     181                 :            :     {
     182                 :            :     public:
     183                 :            :         BroadcastLock (SlideSorter& rSlideSorter);
     184                 :            :         BroadcastLock (PageSelector& rPageSelector);
     185                 :            :         ~BroadcastLock (void);
     186                 :            :     private:
     187                 :            :         PageSelector& mrSelector;
     188                 :            :     };
     189                 :            : 
     190                 :            : private:
     191                 :            :     model::SlideSorterModel& mrModel;
     192                 :            :     SlideSorter& mrSlideSorter;
     193                 :            :     SlideSorterController& mrController;
     194                 :            :     int mnSelectedPageCount;
     195                 :            :     int mnBroadcastDisableLevel;
     196                 :            :     bool mbSelectionChangeBroadcastPending;
     197                 :            :     model::SharedPageDescriptor mpMostRecentlySelectedPage;
     198                 :            :     /// Anchor for a range selection.
     199                 :            :     model::SharedPageDescriptor mpSelectionAnchor;
     200                 :            :     model::SharedPageDescriptor mpCurrentPage;
     201                 :            :     sal_Int32 mnUpdateLockCount;
     202                 :            :     bool mbIsUpdateCurrentPagePending;
     203                 :            : 
     204                 :            :     /** Enable the broadcasting of selection change events.  This calls the
     205                 :            :         SlideSorterController::SelectionHasChanged() method to do the actual
     206                 :            :         work.  When EnableBroadcasting has been called as many times as
     207                 :            :         DisableBroadcasting() was called before and the selection has been
     208                 :            :         changed in the mean time, this change will be broadcasted.
     209                 :            :     */
     210                 :            :     void EnableBroadcasting (void);
     211                 :            : 
     212                 :            :     /** Disable the broadcasting of selection change events.  Subsequent
     213                 :            :         changes of the selection will set a flag that triggers the sending
     214                 :            :         of events when EnableBroadcasting() is called.
     215                 :            :     */
     216                 :            :     void DisableBroadcasting (void);
     217                 :            : 
     218                 :            :     void UpdateCurrentPage (const bool bUpdateOnlyWhenPending = false);
     219                 :            : 
     220                 :            :     void CheckConsistency (void) const;
     221                 :            : };
     222                 :            : 
     223                 :            : } } } // end of namespace ::sd::slidesorter::controller
     224                 :            : 
     225                 :            : #endif
     226                 :            : 
     227                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10