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_SLSCURRENTSLIDEMANAGER_HXX
21 : #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSCURRENTSLIDEMANAGER_HXX
22 :
23 : #include "model/SlsSharedPageDescriptor.hxx"
24 : #include <vcl/timer.hxx>
25 : #include <tools/link.hxx>
26 : #include <com/sun/star/drawing/XDrawPage.hpp>
27 :
28 : class SdPage;
29 :
30 : namespace sd { namespace slidesorter {
31 : class SlideSorter;
32 : } }
33 :
34 : namespace sd { namespace slidesorter { namespace controller {
35 :
36 : /** Manage the current slide. This includes setting the according flags at
37 : the PageDescriptor objects and setting the current slide at the main
38 : view shell.
39 :
40 : Switching pages is triggered only after a little delay. This allows
41 : fast travelling through a larger set of slides without having to wait
42 : for the edit view to update its content after every slide change.
43 : */
44 : class CurrentSlideManager
45 : {
46 : public:
47 : /** Create a new CurrentSlideManager object that manages the current
48 : slide for the given SlideSorter.
49 : */
50 : CurrentSlideManager (SlideSorter& rSlideSorter);
51 :
52 : ~CurrentSlideManager (void);
53 :
54 : /** Call this when the current page of the main view shell has been
55 : switched. Use SwitchCurrentSlide() to initiate such a switch.
56 : */
57 : void NotifyCurrentSlideChange (const sal_Int32 nSlideIndex);
58 : void NotifyCurrentSlideChange (const SdPage* pPage);
59 :
60 : /** Call this method to switch the current page of the main view shell
61 : to the given slide. Use CurrentSlideHasChanged() when the current
62 : slide change has been initiated by someone else.
63 : @param nSlideIndex
64 : Zero based index in the range [0,number-of-slides).
65 : @param bUpdateSelection
66 : When <TRUE/> then the page selection is cleared and only the new
67 : current slide is selected.
68 : */
69 : void SwitchCurrentSlide (
70 : const sal_Int32 nSlideIndex,
71 : const bool bUpdateSelection = false);
72 : void SwitchCurrentSlide (
73 : const model::SharedPageDescriptor& rpSlide,
74 : const bool bUpdateSelection = false);
75 :
76 : /** Return the page descriptor for the current slide. Note, that when
77 : there is no current slide then the returned pointer is empty.
78 : */
79 781 : model::SharedPageDescriptor GetCurrentSlide (void) { return mpCurrentSlide;}
80 :
81 : /** Release all references to model data.
82 : */
83 : void PrepareModelChange (void);
84 :
85 : /** Modify inner state in reaction to a change of the SlideSorterModel.
86 : */
87 : void HandleModelChange (void);
88 :
89 : private:
90 : SlideSorter& mrSlideSorter;
91 : sal_Int32 mnCurrentSlideIndex;
92 : model::SharedPageDescriptor mpCurrentSlide;
93 : /** Timer to control the delay after which to ask
94 : XController/ViewShellBase to switch to another slide.
95 : */
96 : Timer maSwitchPageDelayTimer;
97 :
98 : bool IsCurrentSlideIsValid (void);
99 : void SetCurrentSlideAtViewShellBase (const model::SharedPageDescriptor& rpSlide);
100 : void SetCurrentSlideAtTabControl (const model::SharedPageDescriptor& rpSlide);
101 : void SetCurrentSlideAtXController (const model::SharedPageDescriptor& rpSlide);
102 :
103 : /** When switching from one slide to a new current slide then this
104 : method releases all ties to the old slide.
105 : */
106 : void ReleaseCurrentSlide (void);
107 :
108 : /** When switching from one slide to a new current slide then this
109 : method connects to the new current slide.
110 : */
111 : void AcquireCurrentSlide (const sal_Int32 nSlideIndex);
112 :
113 : DECL_LINK(SwitchPageCallback,void*);
114 : };
115 :
116 : } } } // end of namespace ::sd::slidesorter::controller
117 :
118 : #endif
119 :
120 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|