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 SD_SIDEBAR_LAYOUT_MENU_HXX 25 #define SD_SIDEBAR_LAYOUT_MENU_HXX 26 27 #include "../IDisposable.hxx" 28 #include "../ILayoutableWindow.hxx" 29 #include "../ISidebarReceiver.hxx" 30 31 #include "glob.hxx" 32 #include "pres.hxx" 33 34 #include <vcl/ctrl.hxx> 35 #include <svtools/valueset.hxx> 36 #include <svtools/transfer.hxx> 37 #include <sfx2/shell.hxx> 38 39 #include <com/sun/star/frame/XStatusListener.hpp> 40 #include <com/sun/star/ui/XSidebar.hpp> 41 42 43 class SfxModule; 44 45 namespace css = ::com::sun::star; 46 namespace cssu = ::com::sun::star::uno; 47 48 namespace sd { 49 class DrawDocShell; 50 class PaneManagerEvent; 51 class ViewShellBase; 52 } 53 54 55 namespace sd { namespace tools { 56 class EventMultiplexerEvent; 57 } } 58 59 60 namespace sd { namespace sidebar { 61 62 class ControlFactory; 63 class SidebarViewShell; 64 class SidebarShellManager; 65 66 67 class LayoutMenu 68 : public ValueSet, 69 public SfxShell, 70 public DragSourceHelper, 71 public DropTargetHelper, 72 public ILayoutableWindow, 73 public IDisposable, 74 public ISidebarReceiver 75 { 76 public: 77 TYPEINFO(); 78 SFX_DECL_INTERFACE(SD_IF_SDLAYOUTMENU) 79 80 /** Create a new layout menu. Depending on the given flag it 81 displays its own scroll bar or lets a surrounding window 82 handle that. 83 @param i_pParent 84 the parent node in the control tree 85 @param i_rPanelViewShell 86 the view shell of the task pane. 87 */ 88 LayoutMenu ( 89 ::Window* pParent, 90 ViewShellBase& rViewShellBase, 91 SidebarShellManager& rSubShellManager); 92 virtual ~LayoutMenu (void); 93 94 virtual void Dispose (void); 95 96 /** Return a numerical value representing the currently selected 97 layout. 98 */ 99 AutoLayout GetSelectedAutoLayout (void); 100 101 Size GetPreferredSize (void); 102 sal_Int32 GetPreferredWidth (sal_Int32 nHeight); 103 sal_Int32 GetMinimumWidth (void); 104 105 // From ILayoutableWindow 106 virtual css::ui::LayoutSize GetHeightForWidth (const sal_Int32 nWidth); 107 108 // From ::Window 109 virtual void Paint (const Rectangle& rRect); 110 virtual void Resize (void); 111 112 /** Show a context menu when the right mouse button is pressed. 113 */ 114 virtual void MouseButtonDown (const MouseEvent& rEvent); 115 116 void Execute (SfxRequest& rRequest); 117 void GetState (SfxItemSet& rItemSet); 118 119 /** The LayoutMenu does not support some main views. In this case the 120 LayoutMenu is disabled. This state is updated in this method. 121 @param eMode 122 On some occasions the edit mode is being switched when this 123 method is called can not (yet) be reliably detected. Luckily, 124 in these cases the new value is provided by some broadcaster. 125 On other occasions the edit mode is not modified and is also not 126 provided. Therefore the Unknown value. 127 */ 128 enum MasterMode { MM_NORMAL, MM_MASTER, MM_UNKNOWN }; 129 void UpdateEnabledState (const MasterMode eMode); 130 131 SidebarShellManager* GetShellManager (void); 132 133 /** Call this method when the set of displayed layouts is not up-to-date 134 anymore. It will re-assemple this set according to the current 135 settings. 136 */ 137 void InvalidateContent (void); 138 139 // DragSourceHelper 140 virtual void StartDrag (sal_Int8 nAction, const Point& rPosPixel); 141 142 // DropTargetHelper 143 virtual sal_Int8 AcceptDrop (const AcceptDropEvent& rEvent); 144 virtual sal_Int8 ExecuteDrop (const ExecuteDropEvent& rEvent); 145 146 /** The context menu is requested over this Command() method. 147 */ 148 virtual void Command (const CommandEvent& rEvent); 149 150 /** Call Fill() when switching to or from high contrast mode so that the 151 correct set of icons is displayed. 152 */ 153 virtual void DataChanged (const DataChangedEvent& rEvent); 154 155 // ISidebarReceiver 156 virtual void SetSidebar (const cssu::Reference<css::ui::XSidebar>& rxSidebar); 157 158 using Window::GetWindow; 159 using ValueSet::StartDrag; 160 161 private: 162 ViewShellBase& mrBase; 163 SidebarShellManager& mrShellManager; 164 165 /** Do we use our own scroll bar or is viewport handling done by 166 our parent? 167 */ 168 bool mbUseOwnScrollBar; 169 170 /** If we are asked for the preferred window size, then use this 171 many columns for the calculation. 172 */ 173 const int mnPreferredColumnCount; 174 cssu::Reference<css::frame::XStatusListener> mxListener; 175 bool mbSelectionUpdatePending; 176 bool mbIsMainViewChangePending; 177 cssu::Reference<css::ui::XSidebar> mxSidebar; 178 bool mbIsDisposed; 179 180 /** Calculate the number of displayed rows. This depends on the given 181 item size, the given number of columns, and the size of the 182 control. Note that this is not the number of rows managed by the 183 valueset. This number may be larger. In that case a vertical 184 scroll bar is displayed. 185 */ 186 int CalculateRowCount (const Size& rItemSize, int nColumnCount); 187 188 /** Fill the value set with the layouts that are applicable to the 189 current main view shell. 190 */ 191 void Fill (void); 192 193 /** Remove all items from the value set. 194 */ 195 void Clear (void); 196 197 /** Assign the given layout to all selected slides of a slide sorter. 198 If no slide sorter is active then this call is ignored. The slide 199 sorter in the center pane is preferred if the choice exists. 200 */ 201 void AssignLayoutToSelectedSlides (AutoLayout aLayout); 202 203 /** Insert a new page with the given layout. The page is inserted via 204 the main view shell, i.e. its SID_INSERTPAGE slot is called. It it 205 does not support this slot then inserting a new page does not take 206 place. The new page is inserted after the currently active one (the 207 one returned by ViewShell::GetActualPage().) 208 */ 209 void InsertPageWithLayout (AutoLayout aLayout); 210 211 /** Create a request structure that can be used with the SID_INSERTPAGE 212 and SID_MODIFYPAGE slots. The parameters are set so that the given 213 layout is assigned to the current page of the main view shell. 214 @param nSlotId 215 Supported slots are SID_INSERTPAGE and SID_MODIFYPAGE. 216 @param aLayout 217 Layout of the page to insert or to assign. 218 */ 219 SfxRequest CreateRequest ( 220 sal_uInt16 nSlotId, 221 AutoLayout aLayout); 222 223 /** Select the layout that is used by the current page. 224 */ 225 void UpdateSelection (void); 226 227 // internal ctor 228 void implConstruct( DrawDocShell& rDocumentShell ); 229 230 /** When clicked then set the current page of the view in the center pane. 231 */ 232 DECL_LINK(ClickHandler, ValueSet*); 233 DECL_LINK(RightClickHandler, MouseEvent*); 234 DECL_LINK(StateChangeHandler, ::rtl::OUString*); 235 DECL_LINK(EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*); 236 DECL_LINK(WindowEventHandler, VclWindowEvent*); 237 }; 238 239 } } // end of namespace ::sd::toolpanel 240 241 #endif 242