1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSCURRENTSLIDEMANAGER_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSCURRENTSLIDEMANAGER_HXX
23 #include "model/SlsSharedPageDescriptor.hxx"
24 #include <vcl/timer.hxx>
25 #include <tools/link.hxx>
26 #include <com/sun/star/drawing/XDrawPage.hpp>
30 namespace sd
{ namespace slidesorter
{
34 namespace sd
{ namespace slidesorter
{ namespace controller
{
36 /** Manage the current slide. This includes setting the according flags at
37 the PageDescriptor objects and setting the current slide at the main
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.
44 class CurrentSlideManager
47 /** Create a new CurrentSlideManager object that manages the current
48 slide for the given SlideSorter.
50 CurrentSlideManager (SlideSorter
& rSlideSorter
);
52 ~CurrentSlideManager();
54 /** Call this when the current page of the main view shell has been
55 switched. Use SwitchCurrentSlide() to initiate such a switch.
57 void NotifyCurrentSlideChange (const sal_Int32 nSlideIndex
);
58 void NotifyCurrentSlideChange (const SdPage
* pPage
);
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.
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.
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);
76 /** Return the page descriptor for the current slide. Note, that when
77 there is no current slide then the returned pointer is empty.
79 model::SharedPageDescriptor
GetCurrentSlide() { return mpCurrentSlide
;}
81 /** Release all references to model data.
83 void PrepareModelChange();
85 /** Modify inner state in reaction to a change of the SlideSorterModel.
87 void HandleModelChange();
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.
96 Timer maSwitchPageDelayTimer
;
98 bool IsCurrentSlideIsValid();
99 void SetCurrentSlideAtViewShellBase (const model::SharedPageDescriptor
& rpSlide
);
100 void SetCurrentSlideAtTabControl (const model::SharedPageDescriptor
& rpSlide
);
101 void SetCurrentSlideAtXController (const model::SharedPageDescriptor
& rpSlide
);
103 /** When switching from one slide to a new current slide then this
104 method releases all ties to the old slide.
106 void ReleaseCurrentSlide();
108 /** When switching from one slide to a new current slide then this
109 method connects to the new current slide.
111 void AcquireCurrentSlide (const sal_Int32 nSlideIndex
);
113 DECL_LINK_TYPED(SwitchPageCallback
, Timer
*, void);
116 } } } // end of namespace ::sd::slidesorter::controller
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */