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 SFX_TASKPANE_HXX
21 #define SFX_TASKPANE_HXX
23 #include "sfx2/dllapi.h"
24 #include "sfx2/childwin.hxx"
25 #include "sfx2/titledockwin.hxx"
27 #include <svtools/toolpanel/tabalignment.hxx>
28 #include <svtools/toolpanel/tabitemcontent.hxx>
30 #include <boost/scoped_ptr.hpp>
31 #include <boost/optional.hpp>
38 //......................................................................................................................
41 //......................................................................................................................
43 //==================================================================================================================
44 //= ITaskPaneToolPanelAccess
45 //==================================================================================================================
46 class SAL_NO_VTABLE ITaskPaneToolPanelAccess
49 virtual void ActivateToolPanel( const OUString
& i_rPanelURL
) = 0;
52 ~ITaskPaneToolPanelAccess() {}
55 //==================================================================================================================
57 //==================================================================================================================
58 class SFX2_DLLPUBLIC TaskPaneWrapper
:public SfxChildWindow
59 ,public ITaskPaneToolPanelAccess
65 SfxBindings
* i_pBindings
,
66 SfxChildWinInfo
* i_pInfo
69 SFX_DECL_CHILDWINDOW( TaskPaneWrapper
);
71 // ITaskPaneToolPanelAccess
72 virtual void ActivateToolPanel( const OUString
& i_rPanelURL
);
75 //==================================================================================================================
77 //==================================================================================================================
78 class SFX2_DLLPUBLIC SAL_NO_VTABLE IToolPanelCompare
81 /** compares to tool panel URLs
84 <li>-1 if the tool panel described by i_rLHS should precede the one described by i_rRHS</li>
85 <li>0 if the two panels have no particular relative order</li>
86 <li>1 if the tool panel described by i_rLHS should succeed the one described by i_rRHS</li>
89 virtual short compareToolPanelsURLs(
90 const OUString
& i_rLHS
,
91 const OUString
& i_rRHS
95 ~IToolPanelCompare() {}
98 //==================================================================================================================
100 //==================================================================================================================
101 class ModuleTaskPane_Impl
;
102 /** SFX-less version of a module dependent task pane, filled with tool panels as specified in the respective
103 module's configuration
105 class SFX2_DLLPUBLIC ModuleTaskPane
: public Window
108 /** creates a new instance
109 @param i_rParentWindow
111 @param i_rDocumentFrame
112 the frame to which the task pane belongs. Will be passed to any custom tool panels created
113 via an XUIElementFactory. Also, it is used to determine the module which the task pane is
114 responsible for, thus controlling which tool panels are actually available.
117 Window
& i_rParentWindow
,
118 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& i_rDocumentFrame
120 /** creates a new instance
121 @param i_rParentWindow
123 @param i_rDocumentFrame
124 the frame to which the task pane belongs. Will be passed to any custom tool panels created
125 via an XUIElementFactory. Also, it is used to determine the module which the task pane is
126 responsible for, thus controlling which tool panels are actually available.
128 a comparator for tool panel URLs, which allows controlling the order in which the panels are
129 added to the tool panel deck.
132 Window
& i_rParentWindow
,
133 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& i_rDocumentFrame
,
134 const IToolPanelCompare
& i_rCompare
138 /** determines whether a given module has any registered tool panels
140 static bool ModuleHasToolPanels( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& i_rDocumentFrame
);
142 /** provides access to the Window aspect of the PanelDeck
144 Be careful with this method. For instance, you're not allowed to insert arbitrary IToolPanel implementations
145 into the deck, as the ModuleTaskPane has certain assumptions about the panel implementations. However,
146 you're allowed to remove and re-insert panels, which have originally been created by the ModuleTaskPane
149 ::svt::ToolPanelDeck
& GetPanelDeck();
150 const ::svt::ToolPanelDeck
& GetPanelDeck() const;
152 /** returns the position of the panel with the given resource URL
154 ::boost::optional
< size_t >
155 GetPanelPos( const OUString
& i_rResourceURL
);
157 /** returns the resource URL of the panel at the specified position
160 GetPanelResourceURL( const size_t i_nPanelPos
) const;
162 /// sets the "classical" layout of the tool panel deck, using drawers
163 void SetDrawersLayout();
164 /// sets the new layout of the tool panel deck, using tabs
165 void SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment
, const ::svt::TabItemContent i_eTabContent
);
168 // Window overridables
169 virtual void Resize();
170 virtual void GetFocus();
173 ::boost::scoped_ptr
< ModuleTaskPane_Impl
> m_pImpl
;
176 //==================================================================================================================
177 //= TaskPaneController
178 //==================================================================================================================
179 class TaskPaneController_Impl
;
180 /** is a helper class for connecting a ModuleTaskPane and a TitledDockingWindow, for clients of the ModuleTaskPane
181 which do not use the TaskPaneDockingWindow
183 The controller will add a drop down menu to the docking window which contains one item for each panel in the
184 panel deck, and allows toggling their visibility.
186 class SFX2_DLLPUBLIC TaskPaneController
190 ModuleTaskPane
& i_rTaskPane
,
191 TitledDockingWindow
& i_rDockingWindow
193 ~TaskPaneController();
195 /// activates the panel with the given URL
196 void ActivateToolPanel( const OUString
& i_rPanelURL
);
199 ::boost::scoped_ptr
< TaskPaneController_Impl
> m_pImpl
;
202 //==================================================================================================================
203 //= TaskPaneDockingWindow
204 //==================================================================================================================
205 class TaskPaneDockingWindow
:public TitledDockingWindow
206 ,public ITaskPaneToolPanelAccess
209 TaskPaneDockingWindow( SfxBindings
* i_pBindings
, TaskPaneWrapper
& i_rWrapper
,
210 Window
* i_pParent
, WinBits i_nBits
);
212 // ITaskPaneToolPanelAccess
213 virtual void ActivateToolPanel( const OUString
& i_rPanelURL
);
216 // Window overridables
217 virtual void GetFocus();
219 // TitledDockingWindow overridables
220 virtual void onLayoutDone();
223 ModuleTaskPane m_aTaskPane
;
224 TaskPaneController m_aPaneController
;
227 //......................................................................................................................
229 //......................................................................................................................
231 #endif // SFX_TASKPANE_HXX
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */