Update git submodules
[LibreOffice.git] / sd / source / ui / inc / SlideSorter.hxx
blobc922e5ce4238d75d05f4b05ef64435989483e494
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 <cppuhelper/weakref.hxx>
23 #include <svtools/scrolladaptor.hxx>
24 #include <sddllapi.h>
25 #include <memory>
27 namespace vcl { class Window; }
28 namespace com::sun::star::frame { class XController; }
29 namespace rtl { template <class reference_type> class Reference; }
31 namespace sd {
32 class ViewShell;
33 class ViewShellBase;
34 class Window;
35 class FuPoor;
38 namespace sd::slidesorter::model { class SlideSorterModel; }
40 namespace sd::slidesorter::view {
41 class SlideSorterView;
42 class Theme;
45 namespace sd::slidesorter::controller {
46 class SlideSorterController;
47 class SlotManager;
48 class Properties;
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;
64 public:
65 ~SlideSorter();
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.
73 @param rViewShell
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.
109 @return
110 May be empty.
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.
120 @return
121 May be empty.
123 ViewShellBase* GetViewShellBase() const { return mpViewShellBase;}
125 void Paint (const ::tools::Rectangle& rRepaintArea);
127 /** Place and size the controls and windows. You may want to call this
128 method when something has changed that for instance affects the
129 visibility state of the scroll bars.
131 void ArrangeGUIElements (
132 const Point& rOffset,
133 const Size& rSize);
135 void RelocateToWindow (vcl::Window* pWindow);
137 /** Set the current function at the view shell or, when it is not
138 present, set it at the content window. This method supports the use
139 of functions even when there is no SlideSorterViewShell.
141 void SetCurrentFunction (const rtl::Reference<FuPoor>& rpFunction);
143 /** Return a collection of properties that are used throughout the slide
144 sorter.
146 std::shared_ptr<controller::Properties> const & GetProperties() const;
148 /** Return the active theme which gives access to colors and fonts.
150 std::shared_ptr<view::Theme> const & GetTheme() const;
152 private:
153 /** This virtual method makes it possible to create a specialization of
154 the slide sorter view shell that works with its own implementation
155 of model, view, and controller. The default implementation simply
156 calls the CreateModel(), CreateView(), and CreateController()
157 methods in this order.
159 void CreateModelViewController();
161 /** Create the model for the view shell. When called from the default
162 implementation of CreateModelViewController() then neither view nor
163 controller do exist. Test their pointers when in doubt.
165 model::SlideSorterModel* CreateModel();
167 std::unique_ptr<controller::SlideSorterController> mpSlideSorterController;
168 std::unique_ptr<model::SlideSorterModel> mpSlideSorterModel;
169 std::unique_ptr<view::SlideSorterView> mpSlideSorterView;
170 css::uno::WeakReference<css::frame::XController> mxControllerWeak;
171 ViewShell* mpViewShell;
172 ViewShellBase* mpViewShellBase;
173 VclPtr<sd::Window> mpContentWindow;
174 VclPtr<ScrollAdaptor> mpHorizontalScrollBar;
175 VclPtr<ScrollAdaptor> mpVerticalScrollBar;
177 /** Some slide sorter wide properties that are used in different
178 classes.
180 std::shared_ptr<controller::Properties> mpProperties;
181 std::shared_ptr<view::Theme> mpTheme;
183 SlideSorter (
184 ViewShell& rViewShell,
185 sd::Window* pContentWindow,
186 ScrollAdaptor* pHorizontalScrollBar,
187 ScrollAdaptor* pVerticalScrollBar);
189 void Init();
190 /** Create the controls for the slide sorter. This are the tab bar
191 for switching the edit mode, the scroll bar, and the actual
192 slide sorter view window.
193 This method is usually called exactly one time from the
194 constructor.
196 void SetupControls();
198 /** This method is usually called exactly one time from the
199 constructor.
201 void SetupListeners();
203 /** Release the listeners that have been installed in SetupListeners().
205 void ReleaseListeners();
208 } // end of namespace ::sd::slidesorter
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */