1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SFX_TASKPANE_HXX 25 #define SFX_TASKPANE_HXX 26 27 #include "sfx2/dllapi.h" 28 #include "sfx2/childwin.hxx" 29 #include "sfx2/titledockwin.hxx" 30 31 #include <svtools/toolpanel/tabalignment.hxx> 32 #include <svtools/toolpanel/tabitemcontent.hxx> 33 34 #include <boost/scoped_ptr.hpp> 35 #include <boost/optional.hpp> 36 37 namespace svt 38 { 39 class ToolPanelDeck; 40 } 41 42 //...................................................................................................................... 43 namespace sfx2 44 { 45 //...................................................................................................................... 46 47 //================================================================================================================== 48 //= ITaskPaneToolPanelAccess 49 //================================================================================================================== 50 class SAL_NO_VTABLE ITaskPaneToolPanelAccess 51 { 52 public: 53 virtual void ActivateToolPanel( const ::rtl::OUString& i_rPanelURL ) = 0; 54 }; 55 56 //================================================================================================================== 57 //= TaskPaneWrapper 58 //================================================================================================================== 59 class SFX2_DLLPUBLIC TaskPaneWrapper :public SfxChildWindow 60 ,public ITaskPaneToolPanelAccess 61 { 62 public: 63 TaskPaneWrapper( 64 Window* i_pParent, 65 sal_uInt16 i_nId, 66 SfxBindings* i_pBindings, 67 SfxChildWinInfo* i_pInfo 68 ); 69 70 SFX_DECL_CHILDWINDOW( TaskPaneWrapper ); 71 72 // ITaskPaneToolPanelAccess 73 virtual void ActivateToolPanel( const ::rtl::OUString& i_rPanelURL ); 74 }; 75 76 //================================================================================================================== 77 //= IToolPanelCompare 78 //================================================================================================================== 79 class SFX2_DLLPUBLIC SAL_NO_VTABLE IToolPanelCompare 80 { 81 public: 82 /** compares to tool panel URLs 83 @return 84 <ul> 85 <li>-1 if the tool panel described by i_rLHS should precede the one described by i_rRHS</li> 86 <li>0 if the two panels have no particular relative order</li> 87 <li>1 if the tool panel described by i_rLHS should succeed the one described by i_rRHS</li> 88 89 */ 90 virtual short compareToolPanelsURLs( 91 const ::rtl::OUString& i_rLHS, 92 const ::rtl::OUString& i_rRHS 93 ) const = 0; 94 }; 95 96 //================================================================================================================== 97 //= ModuleTaskPane 98 //================================================================================================================== 99 class ModuleTaskPane_Impl; 100 /** SFX-less version of a module dependent task pane, filled with tool panels as specified in the respective 101 module's configuration 102 */ 103 class SFX2_DLLPUBLIC ModuleTaskPane : public Window 104 { 105 public: 106 /** creates a new instance 107 @param i_rParentWindow 108 the parent window 109 @param i_rDocumentFrame 110 the frame to which the task pane belongs. Will be passed to any custom tool panels created 111 via an XUIElementFactory. Also, it is used to determine the module which the task pane is 112 responsible for, thus controlling which tool panels are actually available. 113 */ 114 ModuleTaskPane( 115 Window& i_rParentWindow, 116 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rDocumentFrame 117 ); 118 /** creates a new instance 119 @param i_rParentWindow 120 the parent window 121 @param i_rDocumentFrame 122 the frame to which the task pane belongs. Will be passed to any custom tool panels created 123 via an XUIElementFactory. Also, it is used to determine the module which the task pane is 124 responsible for, thus controlling which tool panels are actually available. 125 @param i_rCompare 126 a comparator for tool panel URLs, which allows controlling the order in which the panels are 127 added to the tool panel deck. 128 */ 129 ModuleTaskPane( 130 Window& i_rParentWindow, 131 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rDocumentFrame, 132 const IToolPanelCompare& i_rCompare 133 ); 134 ~ModuleTaskPane(); 135 136 /** determines whether a given module has any registered tool panels 137 */ 138 static bool ModuleHasToolPanels( const ::rtl::OUString& i_rModuleIdentifier ); 139 /** determines whether a given module has any registered tool panels 140 */ 141 static bool ModuleHasToolPanels( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rDocumentFrame ); 142 143 /** provides access to the Window aspect of the PanelDeck 144 145 Be careful with this method. For instance, you're not allowed to insert arbitrary IToolPanel implementations 146 into the deck, as the ModuleTaskPane has certain assumptions about the panel implementations. However, 147 you're allowed to remove and re-insert panels, which have originally been created by the ModuleTaskPane 148 itself. 149 */ 150 ::svt::ToolPanelDeck& GetPanelDeck(); 151 const ::svt::ToolPanelDeck& GetPanelDeck() const; 152 153 /** returns the position of the panel with the given resource URL 154 */ 155 ::boost::optional< size_t > 156 GetPanelPos( const ::rtl::OUString& i_rResourceURL ); 157 158 /** returns the resource URL of the panel at the specified position 159 */ 160 ::rtl::OUString 161 GetPanelResourceURL( const size_t i_nPanelPos ) const; 162 163 /// sets the "classical" layout of the tool panel deck, using drawers 164 void SetDrawersLayout(); 165 /// sets the new layout of the tool panel deck, using tabs 166 void SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent ); 167 168 protected: 169 // Window overridables 170 virtual void Resize(); 171 virtual void GetFocus(); 172 173 private: 174 ::boost::scoped_ptr< ModuleTaskPane_Impl > m_pImpl; 175 }; 176 177 //================================================================================================================== 178 //= TaskPaneController 179 //================================================================================================================== 180 class TaskPaneController_Impl; 181 /** is a helper class for connecting a ModuleTaskPane and a TitledDockingWindow, for clients of the ModuleTaskPane 182 which do not use the TaskPaneDockingWindow 183 184 The controller will add a drop down menu to the docking window which contains one item for each panel in the 185 panel deck, and allows toggling their visibility. 186 */ 187 class SFX2_DLLPUBLIC TaskPaneController 188 { 189 public: 190 TaskPaneController( 191 ModuleTaskPane& i_rTaskPane, 192 TitledDockingWindow& i_rDockingWindow 193 ); 194 ~TaskPaneController(); 195 196 /** sets the default title to be used for the TitledDockingWindow 197 198 When the controller switches the docking window to "tabbed" mode, then the title of the docking window 199 will contain the name of the currently active panel (since this name isn't to be seen elsewhere). 200 When the controller switches the docking window to "drawer" mode, then the title of the docking window 201 contains the default title as given here (since in this mode, the names of the panels are shown in 202 the drawers). 203 */ 204 void SetDefaultTitle( const String& i_rTitle ); 205 206 /// activates the panel with the given URL 207 void ActivateToolPanel( const ::rtl::OUString& i_rPanelURL ); 208 209 private: 210 ::boost::scoped_ptr< TaskPaneController_Impl > m_pImpl; 211 }; 212 213 //================================================================================================================== 214 //= TaskPaneDockingWindow 215 //================================================================================================================== 216 class TaskPaneDockingWindow :public TitledDockingWindow 217 ,public ITaskPaneToolPanelAccess 218 { 219 public: 220 TaskPaneDockingWindow( SfxBindings* i_pBindings, TaskPaneWrapper& i_rWrapper, 221 Window* i_pParent, WinBits i_nBits ); 222 223 // ITaskPaneToolPanelAccess 224 virtual void ActivateToolPanel( const ::rtl::OUString& i_rPanelURL ); 225 226 protected: 227 // Window overridables 228 virtual void GetFocus(); 229 230 // TitledDockingWindow overridables 231 virtual void onLayoutDone(); 232 233 private: 234 ModuleTaskPane m_aTaskPane; 235 TaskPaneController m_aPaneController; 236 }; 237 238 //...................................................................................................................... 239 } // namespace sfx2 240 //...................................................................................................................... 241 242 #endif // SFX_TASKPANE_HXX 243