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 .
22 #include <cppuhelper/weakref.hxx>
23 #include <svtools/scrolladaptor.hxx>
27 namespace vcl
{ class Window
; }
28 namespace com::sun::star::frame
{ class XController
; }
29 namespace rtl
{ template <class reference_type
> class Reference
; }
38 namespace sd::slidesorter::model
{ class SlideSorterModel
; }
40 namespace sd::slidesorter::view
{
41 class SlideSorterView
;
45 namespace sd::slidesorter::controller
{
46 class SlideSorterController
;
51 namespace sd::slidesorter
{
53 /** Show previews for all the slides in a document and allow the user to
54 insert or delete slides and modify the order of the slides.
56 This class is a facade for the model, view, and controller classes.
57 It is a hub that allows access to the various parts of a slide sorter.
59 Note that this class is not in its final state.
61 class SlideSorter final
63 friend class controller::SlotManager
;
67 /// Forbid copy construction and copy assignment
68 SlideSorter(const SlideSorter
&) = delete;
69 SlideSorter
& operator=(const SlideSorter
&) = delete;
71 /** Create a new slide sorter that is strongly coupled to the given view
72 shell. Use this function for a slide sorter in the left pane.
74 Typically a SlideSorterViewShell object.
75 @param rpContentWindow
76 Typically the content window of the ViewShell.
77 @param rpHorizontalScrollBar
78 Typically the horizontal scroll bar of the ViewShell.
79 @param rpVerticalScrollBar
80 Typically the vertical scroll bar of the ViewShell.
82 static std::shared_ptr
<SlideSorter
> CreateSlideSorter (
83 ViewShell
& rViewShell
,
84 sd::Window
* pContentWindow
,
85 ScrollAdaptor
* pHorizontalScrollBar
,
86 ScrollAdaptor
* pVerticalScrollBar
);
88 /** Return the control of the vertical scroll bar.
90 const VclPtr
<ScrollAdaptor
>& GetVerticalScrollBar() const { return mpVerticalScrollBar
;}
92 /** Return the control of the horizontal scroll bar.
94 const VclPtr
<ScrollAdaptor
>& GetHorizontalScrollBar() const { return mpHorizontalScrollBar
;}
96 /** Return the content window. This is a sibling and is geometrically
97 enclosed by the scroll bars.
99 const VclPtr
<sd::Window
>& GetContentWindow() const { return mpContentWindow
;}
101 model::SlideSorterModel
& GetModel() const;
103 view::SlideSorterView
& GetView() const;
105 // Exported for unit test
106 SD_DLLPUBLIC
controller::SlideSorterController
& GetController() const;
108 /** Return the view shell that was given at construction.
112 ViewShell
* GetViewShell() const { return mpViewShell
;}
114 /** Return the XController object of the main view.
116 css::uno::Reference
<css::frame::XController
>
117 GetXController() const;
119 /** Return the ViewShellBase object.
123 ViewShellBase
* GetViewShellBase() const { return mpViewShellBase
;}
125 /** Place and size the controls and windows. You may want to call this
126 method when something has changed that for instance affects the
127 visibility state of the scroll bars.
129 void ArrangeGUIElements (
130 const Point
& rOffset
,
133 void RelocateToWindow (vcl::Window
* pWindow
);
135 /** Set the current function at the view shell or, when it is not
136 present, set it at the content window. This method supports the use
137 of functions even when there is no SlideSorterViewShell.
139 void SetCurrentFunction (const rtl::Reference
<FuPoor
>& rpFunction
);
141 /** Return a collection of properties that are used throughout the slide
144 std::shared_ptr
<controller::Properties
> const & GetProperties() const;
146 /** Return the active theme which gives access to colors and fonts.
148 std::shared_ptr
<view::Theme
> const & GetTheme() const;
151 /** This virtual method makes it possible to create a specialization of
152 the slide sorter view shell that works with its own implementation
153 of model, view, and controller. The default implementation simply
154 calls the CreateModel(), CreateView(), and CreateController()
155 methods in this order.
157 void CreateModelViewController();
159 /** Create the model for the view shell. When called from the default
160 implementation of CreateModelViewController() then neither view nor
161 controller do exist. Test their pointers when in doubt.
163 model::SlideSorterModel
* CreateModel();
165 std::unique_ptr
<controller::SlideSorterController
> mpSlideSorterController
;
166 std::unique_ptr
<model::SlideSorterModel
> mpSlideSorterModel
;
167 std::unique_ptr
<view::SlideSorterView
> mpSlideSorterView
;
168 css::uno::WeakReference
<css::frame::XController
> mxControllerWeak
;
169 ViewShell
* mpViewShell
;
170 ViewShellBase
* mpViewShellBase
;
171 VclPtr
<sd::Window
> mpContentWindow
;
172 VclPtr
<ScrollAdaptor
> mpHorizontalScrollBar
;
173 VclPtr
<ScrollAdaptor
> mpVerticalScrollBar
;
175 /** Some slide sorter wide properties that are used in different
178 std::shared_ptr
<controller::Properties
> mpProperties
;
179 std::shared_ptr
<view::Theme
> mpTheme
;
182 ViewShell
& rViewShell
,
183 sd::Window
* pContentWindow
,
184 ScrollAdaptor
* pHorizontalScrollBar
,
185 ScrollAdaptor
* pVerticalScrollBar
);
188 /** Create the controls for the slide sorter. This are the tab bar
189 for switching the edit mode, the scroll bar, and the actual
190 slide sorter view window.
191 This method is usually called exactly one time from the
194 void SetupControls();
196 /** This method is usually called exactly one time from the
199 void SetupListeners();
201 /** Release the listeners that have been installed in SetupListeners().
203 void ReleaseListeners();
206 } // end of namespace ::sd::slidesorter
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */