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