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_INC_SLIDESORTER_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_SLIDESORTER_HXX
23 #include <cppuhelper/weakref.hxx>
24 #include <vcl/scrbar.hxx>
28 namespace vcl
{ class Window
; }
29 namespace com
{ namespace sun
{ namespace star
{ namespace frame
{ class XController
; } } } }
30 namespace rtl
{ template <class reference_type
> class Reference
; }
39 namespace sd
{ namespace slidesorter
{ namespace model
{
40 class SlideSorterModel
;
43 namespace sd
{ namespace slidesorter
{ namespace view
{
44 class SlideSorterView
;
48 namespace sd
{ namespace slidesorter
{ namespace controller
{
49 class SlideSorterController
;
54 namespace sd
{ namespace slidesorter
{
56 /** Show previews for all the slides in a document and allow the user to
57 insert or delete slides and modify the order of the slides.
59 This class is a facade for the model, view, and controller classes.
60 It is a hub that allows access to the various parts of a slide sorter.
62 Note that this class is not in its final state.
64 class SlideSorter final
66 friend class controller::SlotManager
;
70 /// Forbid copy construction and copy assignment
71 SlideSorter(const SlideSorter
&) = delete;
72 SlideSorter
& operator=(const SlideSorter
&) = delete;
74 /** Return whether the called SlideSorter object is valid and calling
75 its Get(Model,View,Controller) methods is safe. When <FALSE/> is
76 called then no other methods should be called.
77 Calling this method should be necessary only during startup and
78 shutdown (when that can be detected).
80 bool IsValid() const { return mbIsValid
;}
82 /** Create a new slide sorter that is strongly coupled to the given view
83 shell. Use this function for a slide sorter in the left pane.
85 Typically a SlideSorterViewShell object.
86 @param rpContentWindow
87 Typically the content window of the ViewShell.
88 @param rpHorizontalScrollBar
89 Typically the horizontal scroll bar of the ViewShell.
90 @param rpVerticalScrollBar
91 Typically the vertical scroll bar of the ViewShell.
93 The little square enclosed by the two scroll bars. Typically
94 the one from the ViewShell.
96 static std::shared_ptr
<SlideSorter
> CreateSlideSorter (
97 ViewShell
& rViewShell
,
98 sd::Window
* pContentWindow
,
99 ScrollBar
* pHorizontalScrollBar
,
100 ScrollBar
* pVerticalScrollBar
,
101 ScrollBarBox
* pScrollBarBox
);
103 /** Create a new slide sorter that is loosely coupled to the given view
104 shell. The view shell may even be missing.
106 ViewShellBase object of the enclosing application.
110 The parent window of the internally created content window and
113 static std::shared_ptr
<SlideSorter
> CreateSlideSorter (
114 ViewShellBase
& rBase
,
115 vcl::Window
& rParentWindow
);
117 /** Return the control of the vertical scroll bar.
119 const VclPtr
<ScrollBar
>& GetVerticalScrollBar() const { return mpVerticalScrollBar
;}
121 /** Return the control of the horizontal scroll bar.
123 const VclPtr
<ScrollBar
>& GetHorizontalScrollBar() const { return mpHorizontalScrollBar
;}
125 /** Return the scroll bar filler that paints the little square that is
126 enclosed by the two scroll bars.
128 const VclPtr
<ScrollBarBox
>& GetScrollBarFiller (void) const { return mpScrollBarBox
;}
130 /** Return the content window. This is a sibling and is geometrically
131 enclosed by the scroll bars.
133 const VclPtr
<sd::Window
>& GetContentWindow() const { return mpContentWindow
;}
135 model::SlideSorterModel
& GetModel() const;
137 view::SlideSorterView
& GetView() const;
139 // Exported for unit test
140 SD_DLLPUBLIC
controller::SlideSorterController
& GetController() const;
142 /** Return the view shell that was given at construction.
146 ViewShell
* GetViewShell() const { return mpViewShell
;}
148 /** Return the XController object of the main view.
150 css::uno::Reference
<css::frame::XController
>
151 GetXController() const;
153 /** Return the ViewShellBase object.
157 ViewShellBase
* GetViewShellBase() const { return mpViewShellBase
;}
159 void Paint (const ::tools::Rectangle
& rRepaintArea
);
161 /** Place and size the controls and windows. You may want to call this
162 method when something has changed that for instance affects the
163 visibility state of the scroll bars.
165 void ArrangeGUIElements (
166 const Point
& rOffset
,
169 void RelocateToWindow (vcl::Window
* pWindow
);
171 /** Set the current function at the view shell or, when it is not
172 present, set it at the content window. This method supports the use
173 of functions even when there is no SlideSorterViewShell.
175 void SetCurrentFunction (const rtl::Reference
<FuPoor
>& rpFunction
);
177 /** Return a collection of properties that are used throughout the slide
180 std::shared_ptr
<controller::Properties
> const & GetProperties() const;
182 /** Return the active theme which gives access to colors and fonts.
184 std::shared_ptr
<view::Theme
> const & GetTheme() const;
187 /** This virtual method makes it possible to create a specialization of
188 the slide sorter view shell that works with its own implementation
189 of model, view, and controller. The default implementation simply
190 calls the CreateModel(), CreateView(), and CreateController()
191 methods in this order.
193 void CreateModelViewController();
195 /** Create the model for the view shell. When called from the default
196 implementation of CreateModelViewController() then neither view nor
197 controller do exist. Test their pointers when in doubt.
199 model::SlideSorterModel
* CreateModel();
203 std::unique_ptr
<controller::SlideSorterController
> mpSlideSorterController
;
204 std::unique_ptr
<model::SlideSorterModel
> mpSlideSorterModel
;
205 std::unique_ptr
<view::SlideSorterView
> mpSlideSorterView
;
206 css::uno::WeakReference
<css::frame::XController
> mxControllerWeak
;
207 ViewShell
* mpViewShell
;
208 ViewShellBase
* mpViewShellBase
;
209 VclPtr
<sd::Window
> mpContentWindow
;
210 VclPtr
<ScrollBar
> mpHorizontalScrollBar
;
211 VclPtr
<ScrollBar
> mpVerticalScrollBar
;
212 VclPtr
<ScrollBarBox
> mpScrollBarBox
;
214 /** Some slide sorter wide properties that are used in different
217 std::shared_ptr
<controller::Properties
> mpProperties
;
218 std::shared_ptr
<view::Theme
> mpTheme
;
221 ViewShell
& rViewShell
,
222 sd::Window
* pContentWindow
,
223 ScrollBar
* pHorizontalScrollBar
,
224 ScrollBar
* pVerticalScrollBar
,
225 ScrollBarBox
* pScrollBarBox
);
227 ViewShellBase
& rBase
,
228 vcl::Window
& rParentWindow
);
231 /** Create the controls for the slide sorter. This are the tab bar
232 for switching the edit mode, the scroll bar, and the actual
233 slide sorter view window.
234 This method is usually called exactly one time from the
237 void SetupControls();
239 /** This method is usually called exactly one time from the
242 void SetupListeners();
244 /** Release the listeners that have been installed in SetupListeners().
246 void ReleaseListeners();
249 } } // end of namespace ::sd::slidesorter
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */