LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - SidebarController.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 2 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARCONTROLLER_HXX
      20             : #define INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARCONTROLLER_HXX
      21             : 
      22             : #include <sal/config.h>
      23             : 
      24             : #include <map>
      25             : 
      26             : #include "AsynchronousCall.hxx"
      27             : #include "Context.hxx"
      28             : #include "FocusManager.hxx"
      29             : #include "Panel.hxx"
      30             : #include "ResourceManager.hxx"
      31             : #include "TabBar.hxx"
      32             : 
      33             : #include <vcl/menu.hxx>
      34             : 
      35             : #include <com/sun/star/awt/XWindowPeer.hpp>
      36             : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
      37             : #include <com/sun/star/frame/XDispatch.hpp>
      38             : #include <com/sun/star/ui/XContextChangeEventListener.hpp>
      39             : #include <com/sun/star/ui/XUIElement.hpp>
      40             : #include <com/sun/star/ui/XSidebar.hpp>
      41             : 
      42             : #include <boost/noncopyable.hpp>
      43             : #include <boost/optional.hpp>
      44             : #include <cppuhelper/compbase4.hxx>
      45             : #include <cppuhelper/basemutex.hxx>
      46             : #include <cppuhelper/weakref.hxx>
      47             : 
      48             : namespace
      49             : {
      50             :     typedef ::cppu::WeakComponentImplHelper4 <
      51             :         css::ui::XContextChangeEventListener,
      52             :         css::beans::XPropertyChangeListener,
      53             :         css::ui::XSidebar,
      54             :         css::frame::XStatusListener
      55             :         > SidebarControllerInterfaceBase;
      56             : }
      57             : 
      58             : class SfxSplitWindow;
      59             : class FixedBitmap;
      60             : 
      61             : namespace sfx2 { namespace sidebar {
      62             : 
      63             : class ContentPanelDescriptor;
      64             : class Deck;
      65             : class DeckDescriptor;
      66             : class SidebarDockingWindow;
      67             : class TabBar;
      68             : class TabBarConfiguration;
      69             : 
      70             : class SidebarController
      71             :     : private ::boost::noncopyable,
      72             :       private ::cppu::BaseMutex,
      73             :       public SidebarControllerInterfaceBase
      74             : {
      75             : public:
      76             :     SidebarController(
      77             :         SidebarDockingWindow* pParentWindow,
      78             :         const css::uno::Reference<css::frame::XFrame>& rxFrame);
      79             :     virtual ~SidebarController();
      80             : 
      81             :     /** Return the SidebarController object that is associated with
      82             :         the given XFrame.
      83             :         @return
      84             :             When there is no SidebarController object for the given
      85             :             XFrame then <NULL/> is returned.
      86             :     */
      87             :     static SidebarController* GetSidebarControllerForFrame (
      88             :         const css::uno::Reference<css::frame::XFrame>& rxFrame);
      89             : 
      90             :     // ui::XContextChangeEventListener
      91             :     virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent)
      92             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      93             : 
      94             :     // XEventListener
      95             :     virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject)
      96             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      97             : 
      98             :     // beans::XPropertyChangeListener
      99             :     virtual void SAL_CALL propertyChange (const css::beans::PropertyChangeEvent& rEvent)
     100             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     101             : 
     102             :     // frame::XStatusListener
     103             :     virtual void SAL_CALL statusChanged (const css::frame::FeatureStateEvent& rEvent)
     104             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     105             : 
     106             :     // ui::XSidebar
     107             :     virtual void SAL_CALL requestLayout()
     108             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     109             : 
     110             :     void NotifyResize();
     111             : 
     112             :     /** In some situations it is necessary to force an update of the
     113             :         current deck and its panels.  One reason is a change of the
     114             :         view scale.  Some panels can handle this only when
     115             :         constructed.  In this case we have to a context change and
     116             :         also force that all panels are destroyed and created new.
     117             :     */
     118             :     const static sal_Int32 SwitchFlag_NoForce = 0x00;
     119             :     const static sal_Int32 SwitchFlag_ForceSwitch = 0x01;
     120             :     const static sal_Int32 SwitchFlag_ForceNewDeck = 0x02;
     121             :     const static sal_Int32 SwitchFlag_ForceNewPanels = 0x02;
     122             : 
     123             :     void OpenThenSwitchToDeck (
     124             :         const ::rtl::OUString& rsDeckId);
     125             : 
     126             :     /** Show only the tab bar, not the deck.
     127             :     */
     128             :     void RequestCloseDeck();
     129             : 
     130             :     /** Open the deck area and restore the parent window to its old width.
     131             :     */
     132             :     void RequestOpenDeck();
     133             : 
     134             :     /** Returns true when the given deck is the currently visible deck
     135             :      */
     136             :     bool IsDeckVisible (const ::rtl::OUString& rsDeckId);
     137             : 
     138           0 :     FocusManager& GetFocusManager() { return maFocusManager;}
     139             : 
     140             : private:
     141             :     typedef ::std::map<
     142             :         const css::uno::Reference<css::frame::XFrame>,
     143             :         css::uno::WeakReference<SidebarController>
     144             :     > SidebarControllerContainer;
     145             :     static SidebarControllerContainer maSidebarControllerContainer;
     146             : 
     147             :     VclPtr<Deck> mpCurrentDeck;
     148             :     VclPtr<SidebarDockingWindow> mpParentWindow;
     149             :     VclPtr<TabBar> mpTabBar;
     150             :     css::uno::Reference<css::frame::XFrame> mxFrame;
     151             :     Context maCurrentContext;
     152             :     Context maRequestedContext;
     153             :     /// Use a combination of SwitchFlag_* as value.
     154             :     sal_Int32 mnRequestedForceFlags;
     155             :     ::rtl::OUString msCurrentDeckId;
     156             :     ::rtl::OUString msCurrentDeckTitle;
     157             :     AsynchronousCall maPropertyChangeForwarder;
     158             :     AsynchronousCall maContextChangeUpdate;
     159             :     AsynchronousCall maAsynchronousDeckSwitch;
     160             : 
     161             :     /** Two flags control whether the deck is displayed or if only the
     162             :         tab bar remains visible.
     163             :         The mbIsDeckOpen flag stores the current state while
     164             :         mbIsDeckRequestedOpen stores how this state should be.  User
     165             :         actions like clicking on the deck closer affect the
     166             :         mbIsDeckRequestedOpen.  Normally both flags have the same
     167             :         value.  A document being read-only can prevent the deck from opening.
     168             :     */
     169             :     ::boost::optional<bool> mbIsDeckRequestedOpen;
     170             :     ::boost::optional<bool> mbIsDeckOpen;
     171             :     bool mbCanDeckBeOpened;
     172             : 
     173             :     /** Before the deck is closed the sidebar width is saved into this variable,
     174             :         so that it can be restored when the deck is reopended.
     175             :     */
     176             :     sal_Int32 mnSavedSidebarWidth;
     177             :     FocusManager maFocusManager;
     178             :     css::uno::Reference<css::frame::XDispatch> mxReadOnlyModeDispatch;
     179             :     bool mbIsDocumentReadOnly;
     180             :     VclPtr<SfxSplitWindow> mpSplitWindow;
     181             :     /** When the user moves the splitter then we remember the
     182             :         width at that time.
     183             :     */
     184             :     sal_Int32 mnWidthOnSplitterButtonDown;
     185             :     /** Control that is temporarily used as replacement for the deck
     186             :         to indicate that when the current mouse drag operation ends, the
     187             :         sidebar will only show the tab bar.
     188             :     */
     189             :     VclPtr<vcl::Window> mpCloseIndicator;
     190             : 
     191             :     DECL_LINK(WindowEventHandler, VclWindowEvent*);
     192             :     /** Make maRequestedContext the current context.
     193             :     */
     194             :     void UpdateConfigurations();
     195             : 
     196             :     css::uno::Reference<css::ui::XUIElement> CreateUIElement (
     197             :         const css::uno::Reference<css::awt::XWindowPeer>& rxWindow,
     198             :         const ::rtl::OUString& rsImplementationURL,
     199             :         const bool bWantsCanvas,
     200             :         const Context& rContext);
     201             :     VclPtr<Panel> CreatePanel (
     202             :         const ::rtl::OUString& rsPanelId,
     203             :         vcl::Window* pParentWindow,
     204             :         const bool bIsInitiallyExpanded,
     205             :         const Context& rContext);
     206             :     void SwitchToDeck (
     207             :         const ::rtl::OUString& rsDeckId);
     208             :     void SwitchToDeck (
     209             :         const DeckDescriptor& rDeckDescriptor,
     210             :         const Context& rContext);
     211             :     void ShowPopupMenu (
     212             :         const Rectangle& rButtonBox,
     213             :         const ::std::vector<TabBar::DeckMenuData>& rMenuData) const;
     214             :     ::boost::shared_ptr<PopupMenu> CreatePopupMenu (
     215             :         const ::std::vector<TabBar::DeckMenuData>& rMenuData) const;
     216             :     DECL_LINK(OnMenuItemSelected, Menu*);
     217             :     void BroadcastPropertyChange();
     218             : 
     219             :     /** The close of the deck changes the width of the child window.
     220             :         That is only possible if there is no other docking window docked above or below the sidebar.
     221             :         Return whether the width of the child window can be modified.
     222             :     */
     223             :     bool CanModifyChildWindowWidth();
     224             : 
     225             :     /** Set the child window container to a new width.
     226             :         Return the old width.
     227             :     */
     228             :     sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth);
     229             : 
     230             :     /** Update the icons displayed in the title bars of the deck and
     231             :         the panels.  This is called once when a deck is created and
     232             :         every time when a data change event is processed.
     233             :     */
     234             :     void UpdateTitleBarIcons();
     235             : 
     236             :     void UpdateDeckOpenState();
     237             :     void RestrictWidth (sal_Int32 nWidth);
     238             :     SfxSplitWindow* GetSplitWindow();
     239             :     void ProcessNewWidth (const sal_Int32 nNewWidth);
     240             :     void UpdateCloseIndicator (const bool bIsIndicatorVisible);
     241             : 
     242             :     /** Typically called when a panel is focused via keyboard.
     243             :         Tries to scroll the deck up or down to make the given panel
     244             :         completely visible.
     245             :     */
     246             :     void ShowPanel (const Panel& rPanel);
     247             : 
     248           0 :     Context GetCurrentContext() const { return maCurrentContext;}
     249             : 
     250             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     251             : };
     252             : 
     253             : } } // end of namespace sfx2::sidebar
     254             : 
     255             : #endif
     256             : 
     257             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11