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_INC_SLIDESORTER_HXX
21 : #define INCLUDED_SD_SOURCE_UI_INC_SLIDESORTER_HXX
22 :
23 : #include "fupoor.hxx"
24 : #include "Window.hxx"
25 : #include <com/sun/star/frame/XController.hpp>
26 : #include <cppuhelper/weakref.hxx>
27 : #include <sfx2/viewfrm.hxx>
28 : #include <boost/noncopyable.hpp>
29 : #include <boost/shared_ptr.hpp>
30 : #include <boost/scoped_ptr.hpp>
31 : #include <boost/current_function.hpp>
32 : #include <vcl/scrbar.hxx>
33 :
34 : class ScrollBar;
35 : class ScrollBarBox;
36 : namespace vcl { class Window; }
37 :
38 : namespace sd {
39 : class ViewShell;
40 : class ViewShellBase;
41 : class Window;
42 : }
43 :
44 : namespace sd { namespace slidesorter { namespace model {
45 : class SlideSorterModel;
46 : } } }
47 :
48 : namespace sd { namespace slidesorter { namespace view {
49 : class SlideSorterView;
50 : class Theme;
51 : } } }
52 :
53 : namespace sd { namespace slidesorter { namespace controller {
54 : class SlideSorterController;
55 : class SlotManager;
56 : class Properties;
57 : } } }
58 :
59 : namespace sd { namespace slidesorter {
60 :
61 : /** Show previews for all the slides in a document and allow the user to
62 : insert or delete slides and modify the order of the slides.
63 :
64 : This class is a facade for the model, view, and controller classes.
65 : It is a hub that allows access to the various parts of a slide sorter.
66 :
67 : Note that this class is not in its final state.
68 : */
69 : class SlideSorter
70 : : private ::boost::noncopyable
71 : {
72 : friend class controller::SlotManager;
73 : public:
74 : virtual ~SlideSorter();
75 :
76 : /** Return whether the called SlideSorter object is valid and calling
77 : its Get(Model,View,Controller) methods is safe. When <FALSE/> is
78 : called then no other methods should be called.
79 : Calling this method should be necessary only during startup and
80 : shutdown (when that can be detected).
81 : */
82 0 : bool IsValid() const { return mbIsValid;}
83 :
84 : /** Create a new slide sorter that is strongly coupled to the given view
85 : shell. Use this function for a slide sorter in the left pane.
86 : @param rViewShell
87 : Typically a SlideSorterViewShell object.
88 : @param rpContentWindow
89 : Typically the content window of the ViewShell.
90 : @param rpHorizontalScrollBar
91 : Typically the horizontal scroll bar of the ViewShell.
92 : @param rpVerticalScrollBar
93 : Typically the vertical scroll bar of the ViewShell.
94 : @param rpScrollBarBox
95 : The little square enclosed by the two scroll bars. Typically
96 : the one from the ViewShell.
97 : */
98 : static ::boost::shared_ptr<SlideSorter> CreateSlideSorter (
99 : ViewShell& rViewShell,
100 : sd::Window* pContentWindow,
101 : ScrollBar* pHorizontalScrollBar,
102 : ScrollBar* pVerticalScrollBar,
103 : ScrollBarBox* pScrollBarBox);
104 :
105 : /** Create a new slide sorter that is losely coupled to the given view
106 : shell. The view shell may even be missing.
107 : @param rBase
108 : ViewShellBase object of the enclosing application.
109 : @param pViewShell
110 : Supply when at hand.
111 : @param rParentWindow
112 : The parent window of the internally created content window and
113 : scroll bars.
114 : */
115 : static ::boost::shared_ptr<SlideSorter> CreateSlideSorter (
116 : ViewShellBase& rBase,
117 : ViewShell* pViewShell,
118 : vcl::Window& rParentWindow);
119 :
120 : /** Return the control of the vertical scroll bar.
121 : */
122 441 : VclPtr<ScrollBar> GetVerticalScrollBar() const { return mpVerticalScrollBar;}
123 :
124 : /** Return the control of the horizontal scroll bar.
125 : */
126 309 : VclPtr<ScrollBar> GetHorizontalScrollBar() const { return mpHorizontalScrollBar;}
127 :
128 : /** Return the scroll bar filler that paints the little square that is
129 : enclosed by the two scroll bars.
130 : */
131 64 : VclPtr<ScrollBarBox> GetScrollBarFiller (void) const { return mpScrollBarBox;}
132 :
133 : /** Return the content window. This is a sibling and is geometrically
134 : enclosed by the scroll bars.
135 : */
136 68315 : VclPtr<sd::Window> GetContentWindow() const { return mpContentWindow;}
137 :
138 : model::SlideSorterModel& GetModel() const;
139 :
140 : view::SlideSorterView& GetView() const;
141 :
142 : controller::SlideSorterController& GetController() const;
143 :
144 : /** Return the view shell that was given at construction.
145 : @return
146 : May be empty.
147 : */
148 1442 : ViewShell* GetViewShell() const { return mpViewShell;}
149 :
150 : /** Return the XController object of the main view.
151 : */
152 : ::com::sun::star::uno::Reference<com::sun::star::frame::XController>
153 : GetXController() const;
154 :
155 : /** Return the ViewShellBase object.
156 : @return
157 : May be empty.
158 : */
159 4500 : ViewShellBase* GetViewShellBase() const { return mpViewShellBase;}
160 :
161 : void Paint (const Rectangle& rRepaintArea);
162 :
163 : /** Place and size the controls and windows. You may want to call this
164 : method when something has changed that for instance affects the
165 : visibility state of the scroll bars.
166 : */
167 : void ArrangeGUIElements (
168 : const Point& rOffset,
169 : const Size& rSize);
170 :
171 : bool RelocateToWindow (vcl::Window* pWindow);
172 :
173 : /** Set the current function at the view shell or, when it is not
174 : present, set it at the content window. This method supports the use
175 : of functions even when there is no SlideSorterViewShell.
176 : */
177 : void SetCurrentFunction (const rtl::Reference<FuPoor>& rpFunction);
178 :
179 : /** Return a collection of properties that are used throughout the slide
180 : sorter.
181 : */
182 : ::boost::shared_ptr<controller::Properties> GetProperties() const;
183 :
184 : /** Return the active theme which gives access to colors and fonts.
185 : */
186 : ::boost::shared_ptr<view::Theme> GetTheme() const;
187 :
188 : protected:
189 : /** This virtual method makes it possible to create a specialization of
190 : the slide sorter view shell that works with its own implementation
191 : of model, view, and controller. The default implementation simply
192 : calls the CreateModel(), CreateView(), and CreateController()
193 : methods in this order.
194 : */
195 : void CreateModelViewController();
196 :
197 : /** Create the model for the view shell. When called from the default
198 : implementation of CreateModelViewController() then neither view nor
199 : controller do exist. Test their pointers when in doubt.
200 : */
201 : model::SlideSorterModel* CreateModel();
202 :
203 : /** Create the view for the view shell. When called from the default
204 : implementation of CreateModelViewController() then the model but not
205 : the controller does exist. Test their pointers when in doubt.
206 : */
207 : view::SlideSorterView* CreateView();
208 :
209 : /** Create the controller for the view shell. When called from the default
210 : implementation of CreateModelViewController() then both the view and
211 : the controller do exist. Test their pointers when in doubt.
212 : */
213 : controller::SlideSorterController* CreateController();
214 :
215 : private:
216 : bool mbIsValid;
217 :
218 : ::boost::scoped_ptr<controller::SlideSorterController> mpSlideSorterController;
219 : ::boost::scoped_ptr<model::SlideSorterModel> mpSlideSorterModel;
220 : ::boost::scoped_ptr<view::SlideSorterView> mpSlideSorterView;
221 : ::com::sun::star::uno::WeakReference<com::sun::star::frame::XController> mxControllerWeak;
222 : ViewShell* mpViewShell;
223 : ViewShellBase* mpViewShellBase;
224 : VclPtr<sd::Window> mpContentWindow;
225 : bool mbOwnesContentWindow;
226 : VclPtr<ScrollBar> mpHorizontalScrollBar;
227 : VclPtr<ScrollBar> mpVerticalScrollBar;
228 : VclPtr<ScrollBarBox> mpScrollBarBox;
229 :
230 : /** Set this flag to <TRUE/> to force a layout before the next paint.
231 : */
232 : bool mbLayoutPending;
233 :
234 : /** Some slide sorter wide properties that are used in different
235 : classes.
236 : */
237 : ::boost::shared_ptr<controller::Properties> mpProperties;
238 : ::boost::shared_ptr<view::Theme> mpTheme;
239 :
240 : SlideSorter (
241 : ViewShell& rViewShell,
242 : sd::Window* pContentWindow,
243 : ScrollBar* pHorizontalScrollBar,
244 : ScrollBar* pVerticalScrollBar,
245 : ScrollBarBox* pScrollBarBox);
246 : SlideSorter (
247 : ViewShellBase& rBase,
248 : ViewShell* pViewShell,
249 : vcl::Window& rParentWindow);
250 :
251 : void Init();
252 : /** Create the controls for the slide sorter. This are the tab bar
253 : for switching the edit mode, the scroll bar, and the actual
254 : slide sorter view window.
255 : This method is usually called exactly one time from the
256 : constructor.
257 : */
258 : void SetupControls (vcl::Window* pParentWindow);
259 :
260 : /** This method is usually called exactly one time from the
261 : constructor.
262 : */
263 : void SetupListeners();
264 :
265 : /** Release the listeners that have been installed in SetupListeners().
266 : */
267 : void ReleaseListeners();
268 : };
269 :
270 : } } // end of namespace ::sd::slidesorter
271 :
272 : #endif
273 :
274 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|