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_SFX2_TASKPANE_HXX
21 : #define INCLUDED_SFX2_TASKPANE_HXX
22 :
23 : #include <sfx2/dllapi.h>
24 : #include <sfx2/childwin.hxx>
25 : #include <sfx2/titledockwin.hxx>
26 :
27 : #include <svtools/toolpanel/tabalignment.hxx>
28 : #include <svtools/toolpanel/tabitemcontent.hxx>
29 :
30 : #include <boost/optional.hpp>
31 :
32 : namespace svt
33 : {
34 : class ToolPanelDeck;
35 : }
36 :
37 :
38 : namespace sfx2
39 : {
40 :
41 :
42 :
43 : //= ITaskPaneToolPanelAccess
44 :
45 0 : class SAL_NO_VTABLE ITaskPaneToolPanelAccess
46 : {
47 : public:
48 : virtual void ActivateToolPanel( const OUString& i_rPanelURL ) = 0;
49 :
50 : protected:
51 0 : ~ITaskPaneToolPanelAccess() {}
52 : };
53 :
54 :
55 : //= TaskPaneWrapper
56 :
57 0 : class SFX2_DLLPUBLIC TaskPaneWrapper :public SfxChildWindow
58 : ,public ITaskPaneToolPanelAccess
59 : {
60 : public:
61 : TaskPaneWrapper(
62 : vcl::Window* i_pParent,
63 : sal_uInt16 i_nId,
64 : SfxBindings* i_pBindings,
65 : SfxChildWinInfo* i_pInfo
66 : );
67 :
68 : SFX_DECL_CHILDWINDOW( TaskPaneWrapper );
69 :
70 : // ITaskPaneToolPanelAccess
71 : virtual void ActivateToolPanel( const OUString& i_rPanelURL ) SAL_OVERRIDE;
72 : };
73 :
74 :
75 : //= ModuleTaskPane
76 :
77 : class ModuleTaskPane_Impl;
78 : /** SFX-less version of a module dependent task pane, filled with tool panels as specified in the respective
79 : module's configuration
80 : */
81 : class SFX2_DLLPUBLIC ModuleTaskPane : public vcl::Window
82 : {
83 : public:
84 : /** creates a new instance
85 : @param i_rParentWindow
86 : the parent window
87 : @param i_rDocumentFrame
88 : the frame to which the task pane belongs. Will be passed to any custom tool panels created
89 : via an XUIElementFactory. Also, it is used to determine the module which the task pane is
90 : responsible for, thus controlling which tool panels are actually available.
91 : */
92 : ModuleTaskPane(
93 : vcl::Window& i_rParentWindow,
94 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rDocumentFrame
95 : );
96 : virtual ~ModuleTaskPane();
97 :
98 : /** determines whether a given module has any registered tool panels
99 : */
100 : static bool ModuleHasToolPanels( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rDocumentFrame );
101 :
102 : /** provides access to the Window aspect of the PanelDeck
103 :
104 : Be careful with this method. For instance, you're not allowed to insert arbitrary IToolPanel implementations
105 : into the deck, as the ModuleTaskPane has certain assumptions about the panel implementations. However,
106 : you're allowed to remove and re-insert panels, which have originally been created by the ModuleTaskPane
107 : itself.
108 : */
109 : ::svt::ToolPanelDeck& GetPanelDeck();
110 : const ::svt::ToolPanelDeck& GetPanelDeck() const;
111 :
112 : /** returns the position of the panel with the given resource URL
113 : */
114 : ::boost::optional< size_t >
115 : GetPanelPos( const OUString& i_rResourceURL );
116 :
117 : /// sets the "classical" layout of the tool panel deck, using drawers
118 : void SetDrawersLayout();
119 : /// sets the new layout of the tool panel deck, using tabs
120 : void SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent );
121 :
122 : protected:
123 : // Window overridables
124 : virtual void Resize() SAL_OVERRIDE;
125 : virtual void GetFocus() SAL_OVERRIDE;
126 :
127 : private:
128 : std::unique_ptr<ModuleTaskPane_Impl> m_xImpl;
129 : };
130 :
131 :
132 : //= TaskPaneController
133 :
134 : class TaskPaneController_Impl;
135 : /** is a helper class for connecting a ModuleTaskPane and a TitledDockingWindow, for clients of the ModuleTaskPane
136 : which do not use the TaskPaneDockingWindow
137 :
138 : The controller will add a drop down menu to the docking window which contains one item for each panel in the
139 : panel deck, and allows toggling their visibility.
140 : */
141 : class SFX2_DLLPUBLIC TaskPaneController
142 : {
143 : public:
144 : TaskPaneController(
145 : ModuleTaskPane& i_rTaskPane,
146 : TitledDockingWindow& i_rDockingWindow
147 : );
148 : ~TaskPaneController();
149 :
150 : /// activates the panel with the given URL
151 : void ActivateToolPanel( const OUString& i_rPanelURL );
152 :
153 : private:
154 : std::unique_ptr<TaskPaneController_Impl> m_xImpl;
155 : };
156 :
157 :
158 : //= TaskPaneDockingWindow
159 :
160 : class TaskPaneDockingWindow :public TitledDockingWindow
161 : ,public ITaskPaneToolPanelAccess
162 : {
163 : public:
164 : TaskPaneDockingWindow( SfxBindings* i_pBindings, TaskPaneWrapper& i_rWrapper,
165 : vcl::Window* i_pParent, WinBits i_nBits );
166 : virtual ~TaskPaneDockingWindow();
167 : virtual void dispose() SAL_OVERRIDE;
168 :
169 : // ITaskPaneToolPanelAccess
170 : virtual void ActivateToolPanel( const OUString& i_rPanelURL ) SAL_OVERRIDE;
171 :
172 : protected:
173 : // Window overridables
174 : virtual void GetFocus() SAL_OVERRIDE;
175 :
176 : // TitledDockingWindow overridables
177 : virtual void onLayoutDone() SAL_OVERRIDE;
178 :
179 : private:
180 : VclPtr<ModuleTaskPane> m_aTaskPane;
181 : TaskPaneController m_aPaneController;
182 : };
183 :
184 :
185 : } // namespace sfx2
186 :
187 :
188 : #endif // INCLUDED_SFX2_TASKPANE_HXX
189 :
190 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|