LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/inc/controller - SlideSorterController.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_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             :     void Init();
      74             : 
      75             :     virtual ~SlideSorterController();
      76             : 
      77             :     void Dispose();
      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();
     110             :     FocusManager& GetFocusManager();
     111             :     controller::Clipboard& GetClipboard();
     112             : 
     113             :     /** Return the object that manages the scroll bars.
     114             :     */
     115             :     ScrollBarManager& GetScrollBarManager();
     116             : 
     117             :     ::boost::shared_ptr<CurrentSlideManager> GetCurrentSlideManager() const;
     118             :     ::boost::shared_ptr<SlotManager> GetSlotManager() const;
     119             :     ::boost::shared_ptr<SelectionManager> GetSelectionManager() const;
     120             :     ::boost::shared_ptr<InsertionIndicatorHandler> GetInsertionIndicatorHandler() 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             : 
     140             :     bool IsLocked() const;
     141             : 
     142             :     /** Create an object of this inner class to prevent updates due to model
     143             :         changes.
     144             :     */
     145             :     class ModelChangeLock
     146             :     {public:
     147             :         ModelChangeLock (SlideSorterController& rController);
     148             :         ~ModelChangeLock();
     149             :         void Release();
     150             :     private:
     151             :         SlideSorterController* mpController;
     152             :     };
     153             :     friend class ModelChangeLock;
     154             : 
     155             :     /** Handle a change of the model, that is, handle the removal and
     156             :         insertion of whole pages or a change of the edit mode.
     157             : 
     158             :         This method is a convenience function that simply calls
     159             :         PreModelChange() and then PostModelChange().
     160             :     */
     161             :     void HandleModelChange();
     162             : 
     163             :     DECL_LINK(WindowEventHandler, VclWindowEvent*);
     164             : 
     165             :     /** Update the display of all pages.  This involves a redraw and
     166             :         releasing previews and caches.
     167             :     */
     168             :     void UpdateAllPages();
     169             : 
     170             :     /** This factory method creates a selection function.
     171             :     */
     172             :     rtl::Reference<FuPoor> CreateSelectionFunction (SfxRequest& rRequest);
     173             : 
     174             :     /** When the current function of the view shell is the slide sorter
     175             :         selection function then return a reference to it.  Otherwise return
     176             :         an empty reference.
     177             :     */
     178             :     ::rtl::Reference<SelectionFunction> GetCurrentSelectionFunction();
     179             : 
     180             :     /** Prepare for a change of the edit mode.  Depending on the current
     181             :         edit mode we may save the selection so that it can be restored when
     182             :         later changing back to the current edit mode.
     183             :     */
     184             :     void PrepareEditModeChange();
     185             : 
     186             :     /** Set a new edit mode and return whether the edit mode really
     187             :         has been changed.  For proper saving and restoring of the selection
     188             :         this method should be called between calls to
     189             :         PrepareEditModeChange() and FinishEditModeChange().
     190             :         @return
     191             :             A return value of <TRUE/> indicates that the edit mode has
     192             :             changed.
     193             :     */
     194             :     bool ChangeEditMode (EditMode eEditMode);
     195             : 
     196             :     /** Finish the change of the edit mode.  Here we may select a page or
     197             :         restore a previously saved selection.
     198             :     */
     199             :     void FinishEditModeChange();
     200             : 
     201             :     /** Call this method when the name of one of the pages has changed.
     202             :         This is then notified to the accessibility object, when that exists.
     203             :         @param nPageIndex
     204             :             The index of the page whose name has been changed.
     205             :         @param rsOldName
     206             :             The old name of the page.  The new name can be taken from the
     207             :             page object.
     208             :     */
     209             :     void PageNameHasChanged (int nPageIndex, const OUString& rsOldName);
     210             : 
     211             :     /** Provide the set of pages to be displayed in the slide sorter.  The
     212             :         GetDocumentSlides() method can be found only in the SlideSorterModel.
     213             :     */
     214             :     void SetDocumentSlides (const css::uno::Reference<css::container::XIndexAccess>& rxSlides);
     215             : 
     216             :     /** Return an Animator object.
     217             :     */
     218          68 :     ::boost::shared_ptr<Animator> GetAnimator() const { return mpAnimator;}
     219             : 
     220             :     VisibleAreaManager& GetVisibleAreaManager() const;
     221             : 
     222             :     void CheckForMasterPageAssignment();
     223             :     void CheckForSlideTransitionAssignment();
     224             : 
     225             : private:
     226             :     SlideSorter& mrSlideSorter;
     227             :     model::SlideSorterModel& mrModel;
     228             :     view::SlideSorterView& mrView;
     229             :     ::boost::scoped_ptr<PageSelector> mpPageSelector;
     230             :     ::boost::scoped_ptr<FocusManager> mpFocusManager;
     231             :     ::boost::shared_ptr<SlotManager> mpSlotManager;
     232             :     ::boost::scoped_ptr<ScrollBarManager> mpScrollBarManager;
     233             :     mutable ::boost::shared_ptr<CurrentSlideManager> mpCurrentSlideManager;
     234             :     ::boost::shared_ptr<SelectionManager> mpSelectionManager;
     235             :     ::boost::scoped_ptr<controller::Clipboard> mpClipboard;
     236             :     ::boost::shared_ptr<InsertionIndicatorHandler> mpInsertionIndicatorHandler;
     237             :     ::boost::shared_ptr<Animator> mpAnimator;
     238             :     ::boost::scoped_ptr<VisibleAreaManager> mpVisibleAreaManager;
     239             : 
     240             :     // The listener listens to UNO events and thus is a UNO object.
     241             :     ::rtl::Reference<controller::Listener> mpListener;
     242             : 
     243             :     int mnModelChangeLockCount;
     244             :     bool mbIsForcedRearrangePending;
     245             : 
     246             :     bool mbPreModelChangeDone;
     247             :     bool mbPostModelChangePending;
     248             : 
     249             :     ::std::vector<Link<>> maSelectionChangeListeners;
     250             : 
     251             :     /** This array stores the indices of the  selected page descriptors at
     252             :         the time when the edit mode is switched to EM_MASTERPAGE.  With this
     253             :         we can restore the selection when switching back to EM_PAGE mode.
     254             :     */
     255             :     ::std::vector<SdPage*> maSelectionBeforeSwitch;
     256             :     /// The current page before the edit mode is switched to EM_MASTERPAGE.
     257             :     int mnCurrentPageBeforeSwitch;
     258             : 
     259             :     /** The master page to select after the edit mode is changed.  This
     260             :         member is used to pass the pointer from PrepareEditModeChange() to
     261             :         FinishEditModeChange().
     262             :     */
     263             :     SdPage* mpEditModeChangeMasterPage;
     264             : 
     265             :     /** This rectangle in the parent window encloses scroll bars and slide
     266             :         sorter window.  It is set when Resize() is called.
     267             :     */
     268             :     Rectangle maTotalWindowArea;
     269             : 
     270             :     /** This counter is used to avoid processing of reentrant calls to
     271             :         Paint().
     272             :     */
     273             :     sal_Int32 mnPaintEntranceCount;
     274             : 
     275             :     /** Remember whether the context menu is open.
     276             :     */
     277             :     bool mbIsContextMenuOpen;
     278             : 
     279             :     /** Delete the given list of normal pages.  This method is a helper
     280             :         function for DeleteSelectedPages().
     281             :         @param rSelectedNormalPages
     282             :             A list of normal pages.  Supplying master pages is an error.
     283             :     */
     284             :     void DeleteSelectedNormalPages (const ::std::vector<SdPage*>& rSelectedNormalPages);
     285             : 
     286             :     /** Delete the given list of master pages.  This method is a helper
     287             :         function for DeleteSelectedPages().
     288             :         @param rSelectedMasterPages
     289             :             A list of master pages.  Supplying normal pages is an error.
     290             :     */
     291             :     void DeleteSelectedMasterPages (const ::std::vector<SdPage*>& rSelectedMasterPages);
     292             : 
     293             :     /** Prepare for several model changes, i.e. prevent time-consuming and
     294             :         non-critical operations like repaints until UnlockModelChange() is
     295             :         called.  Ciritcal operations like releasing references to pages that
     296             :         do not exist anymore are executed.
     297             :     */
     298             :     void LockModelChange();
     299             : 
     300             :     /** Further calls to HandleModelChange() will result in a full featured
     301             :         update of model, view, and controller.  When HandleModelChange() has
     302             :         been called since the last LockModelChange() then this is done right
     303             :         away to bring the view up-to-date.
     304             :     */
     305             :     void UnlockModelChange();
     306             : 
     307             :     /** Prepare for a model change.  This method does all the things that
     308             :         need to be done _before_ the model changes, e.g. because they need
     309             :         access to the model data before the change.
     310             :     */
     311             :     void PreModelChange();
     312             : 
     313             :     /** Complete a model change.  This includes the recreation of data
     314             :         structures that depend on the model and the request for a repaint to
     315             :         show the changes.
     316             :     */
     317             :     void PostModelChange();
     318             : };
     319             : 
     320             : } } } // end of namespace ::sd::slidesorter::controller
     321             : 
     322             : #endif
     323             : 
     324             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11