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