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 /** Call this method when the set of displayed layouts is not up-to-date 109*02c50d82SAndre Fischer anymore. It will re-assemple this set according to the current 110*02c50d82SAndre Fischer settings. 111*02c50d82SAndre Fischer */ 112*02c50d82SAndre Fischer void InvalidateContent (void); 113*02c50d82SAndre Fischer 114*02c50d82SAndre Fischer // DragSourceHelper 115*02c50d82SAndre Fischer virtual void StartDrag (sal_Int8 nAction, const Point& rPosPixel); 116*02c50d82SAndre Fischer 117*02c50d82SAndre Fischer // DropTargetHelper 118*02c50d82SAndre Fischer virtual sal_Int8 AcceptDrop (const AcceptDropEvent& rEvent); 119*02c50d82SAndre Fischer virtual sal_Int8 ExecuteDrop (const ExecuteDropEvent& rEvent); 120*02c50d82SAndre Fischer 121*02c50d82SAndre Fischer /** The context menu is requested over this Command() method. 122*02c50d82SAndre Fischer */ 123*02c50d82SAndre Fischer virtual void Command (const CommandEvent& rEvent); 124*02c50d82SAndre Fischer 125*02c50d82SAndre Fischer /** Call Fill() when switching to or from high contrast mode so that the 126*02c50d82SAndre Fischer correct set of icons is displayed. 127*02c50d82SAndre Fischer */ 128*02c50d82SAndre Fischer virtual void DataChanged (const DataChangedEvent& rEvent); 129*02c50d82SAndre Fischer 130*02c50d82SAndre Fischer using Window::GetWindow; 131*02c50d82SAndre Fischer using ValueSet::StartDrag; 132*02c50d82SAndre Fischer 133*02c50d82SAndre Fischer private: 134*02c50d82SAndre Fischer ViewShellBase& mrBase; 135*02c50d82SAndre Fischer 136*02c50d82SAndre Fischer /** Do we use our own scroll bar or is viewport handling done by 137*02c50d82SAndre Fischer our parent? 138*02c50d82SAndre Fischer */ 139*02c50d82SAndre Fischer bool mbUseOwnScrollBar; 140*02c50d82SAndre Fischer 141*02c50d82SAndre Fischer /** If we are asked for the preferred window size, then use this 142*02c50d82SAndre Fischer many columns for the calculation. 143*02c50d82SAndre Fischer */ 144*02c50d82SAndre Fischer const int mnPreferredColumnCount; 145*02c50d82SAndre Fischer cssu::Reference<css::frame::XStatusListener> mxListener; 146*02c50d82SAndre Fischer bool mbSelectionUpdatePending; 147*02c50d82SAndre Fischer bool mbIsMainViewChangePending; 148*02c50d82SAndre Fischer cssu::Reference<css::ui::XSidebar> mxSidebar; 149*02c50d82SAndre Fischer bool mbIsDisposed; 150*02c50d82SAndre Fischer 151*02c50d82SAndre Fischer /** Calculate the number of displayed rows. This depends on the given 152*02c50d82SAndre Fischer item size, the given number of columns, and the size of the 153*02c50d82SAndre Fischer control. Note that this is not the number of rows managed by the 154*02c50d82SAndre Fischer valueset. This number may be larger. In that case a vertical 155*02c50d82SAndre Fischer scroll bar is displayed. 156*02c50d82SAndre Fischer */ 157*02c50d82SAndre Fischer int CalculateRowCount (const Size& rItemSize, int nColumnCount); 158*02c50d82SAndre Fischer 159*02c50d82SAndre Fischer /** Fill the value set with the layouts that are applicable to the 160*02c50d82SAndre Fischer current main view shell. 161*02c50d82SAndre Fischer */ 162*02c50d82SAndre Fischer void Fill (void); 163*02c50d82SAndre Fischer 164*02c50d82SAndre Fischer /** Remove all items from the value set. 165*02c50d82SAndre Fischer */ 166*02c50d82SAndre Fischer void Clear (void); 167*02c50d82SAndre Fischer 168*02c50d82SAndre Fischer /** Assign the given layout to all selected slides of a slide sorter. 169*02c50d82SAndre Fischer If no slide sorter is active then this call is ignored. The slide 170*02c50d82SAndre Fischer sorter in the center pane is preferred if the choice exists. 171*02c50d82SAndre Fischer */ 172*02c50d82SAndre Fischer void AssignLayoutToSelectedSlides (AutoLayout aLayout); 173*02c50d82SAndre Fischer 174*02c50d82SAndre Fischer /** Insert a new page with the given layout. The page is inserted via 175*02c50d82SAndre Fischer the main view shell, i.e. its SID_INSERTPAGE slot is called. It it 176*02c50d82SAndre Fischer does not support this slot then inserting a new page does not take 177*02c50d82SAndre Fischer place. The new page is inserted after the currently active one (the 178*02c50d82SAndre Fischer one returned by ViewShell::GetActualPage().) 179*02c50d82SAndre Fischer */ 180*02c50d82SAndre Fischer void InsertPageWithLayout (AutoLayout aLayout); 181*02c50d82SAndre Fischer 182*02c50d82SAndre Fischer /** Create a request structure that can be used with the SID_INSERTPAGE 183*02c50d82SAndre Fischer and SID_MODIFYPAGE slots. The parameters are set so that the given 184*02c50d82SAndre Fischer layout is assigned to the current page of the main view shell. 185*02c50d82SAndre Fischer @param nSlotId 186*02c50d82SAndre Fischer Supported slots are SID_INSERTPAGE and SID_MODIFYPAGE. 187*02c50d82SAndre Fischer @param aLayout 188*02c50d82SAndre Fischer Layout of the page to insert or to assign. 189*02c50d82SAndre Fischer */ 190*02c50d82SAndre Fischer SfxRequest CreateRequest ( 191*02c50d82SAndre Fischer sal_uInt16 nSlotId, 192*02c50d82SAndre Fischer AutoLayout aLayout); 193*02c50d82SAndre Fischer 194*02c50d82SAndre Fischer /** Select the layout that is used by the current page. 195*02c50d82SAndre Fischer */ 196*02c50d82SAndre Fischer void UpdateSelection (void); 197*02c50d82SAndre Fischer 198*02c50d82SAndre Fischer // internal ctor 199*02c50d82SAndre Fischer void implConstruct( DrawDocShell& rDocumentShell ); 200*02c50d82SAndre Fischer 201*02c50d82SAndre Fischer /** When clicked then set the current page of the view in the center pane. 202*02c50d82SAndre Fischer */ 203*02c50d82SAndre Fischer DECL_LINK(ClickHandler, ValueSet*); 204*02c50d82SAndre Fischer DECL_LINK(RightClickHandler, MouseEvent*); 205*02c50d82SAndre Fischer DECL_LINK(StateChangeHandler, ::rtl::OUString*); 206*02c50d82SAndre Fischer DECL_LINK(EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*); 207*02c50d82SAndre Fischer DECL_LINK(WindowEventHandler, VclWindowEvent*); 208*02c50d82SAndre Fischer DECL_LINK(OnMenuItemSelected, Menu*); 209*02c50d82SAndre Fischer }; 210*02c50d82SAndre Fischer 211*02c50d82SAndre Fischer } } // end of namespace ::sd::toolpanel 212*02c50d82SAndre Fischer 213*02c50d82SAndre Fischer #endif 214