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