Update git submodules
[LibreOffice.git] / sd / source / ui / slidesorter / inc / controller / SlsCurrentSlideManager.hxx
blob0c5b3b24399a736b45c2831037f5a5b78e177350
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 #pragma once
22 #include <model/SlsSharedPageDescriptor.hxx>
23 #include <vcl/timer.hxx>
24 #include <tools/link.hxx>
26 class SdPage;
28 namespace sd::slidesorter
30 class SlideSorter;
33 namespace sd::slidesorter::controller
35 /** Manage the current slide. This includes setting the according flags at
36 the PageDescriptor objects and setting the current slide at the main
37 view shell.
39 Switching pages is triggered only after a little delay. This allows
40 fast travelling through a larger set of slides without having to wait
41 for the edit view to update its content after every slide change.
43 class CurrentSlideManager
45 public:
46 /** Create a new CurrentSlideManager object that manages the current
47 slide for the given SlideSorter.
49 CurrentSlideManager(SlideSorter& rSlideSorter);
51 ~CurrentSlideManager();
53 /** Call this when the current page of the main view shell has been
54 switched. Use SwitchCurrentSlide() to initiate such a switch.
56 void NotifyCurrentSlideChange(const sal_Int32 nSlideIndex);
57 void NotifyCurrentSlideChange(const SdPage* pPage);
59 /** Call this method to switch the current page of the main view shell
60 to the given slide. Use CurrentSlideHasChanged() when the current
61 slide change has been initiated by someone else.
62 @param nSlideIndex
63 Zero based index in the range [0,number-of-slides).
64 The page selection is cleared and only the new
65 current slide is selected.
67 void SwitchCurrentSlide(const sal_Int32 nSlideIndex);
68 void SwitchCurrentSlide(const model::SharedPageDescriptor& rpSlide,
69 const bool bUpdateSelection = false);
71 /** Return the page descriptor for the current slide. Note, that when
72 there is no current slide then the returned pointer is empty.
74 const model::SharedPageDescriptor& GetCurrentSlide() const { return mpCurrentSlide; }
76 /** Release all references to model data.
78 void PrepareModelChange();
80 /** Modify inner state in reaction to a change of the SlideSorterModel.
82 void HandleModelChange();
84 private:
85 SlideSorter& mrSlideSorter;
86 sal_Int32 mnCurrentSlideIndex;
87 model::SharedPageDescriptor mpCurrentSlide;
88 /** Timer to control the delay after which to ask
89 XController/ViewShellBase to switch to another slide.
91 Timer maSwitchPageDelayTimer;
93 void SetCurrentSlideAtViewShellBase(const model::SharedPageDescriptor& rpSlide);
94 void SetCurrentSlideAtTabControl(const model::SharedPageDescriptor& rpSlide);
95 void SetCurrentSlideAtXController(const model::SharedPageDescriptor& rpSlide);
97 /** When switching from one slide to a new current slide then this
98 method releases all ties to the old slide.
100 void ReleaseCurrentSlide();
102 /** When switching from one slide to a new current slide then this
103 method connects to the new current slide.
105 void AcquireCurrentSlide(const sal_Int32 nSlideIndex);
107 DECL_LINK(SwitchPageCallback, Timer*, void);
110 } // end of namespace ::sd::slidesorter::controller
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */