LCOV - code coverage report
Current view: top level - include/sfx2/sidebar - ControllerItem.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 1 0.0 %
Date: 2014-04-11 Functions: 0 1 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_SIDEBAR_CONTROLLERITEM_HXX
      20             : #define INCLUDED_SFX2_SIDEBAR_CONTROLLERITEM_HXX
      21             : 
      22             : #include <sfx2/ctrlitem.hxx>
      23             : 
      24             : #include <cppuhelper/compbase1.hxx>
      25             : #include <cppuhelper/basemutex.hxx>
      26             : #include <unotools/cmdoptions.hxx>
      27             : #include <vcl/image.hxx>
      28             : 
      29             : #include <com/sun/star/frame/XFrame.hpp>
      30             : 
      31             : #include <boost/function.hpp>
      32             : 
      33             : namespace cssu = ::com::sun::star::uno;
      34             : 
      35             : class SfxViewFrame;
      36             : class ToolBox;
      37             : 
      38             : 
      39             : namespace sfx2 { namespace sidebar {
      40             : 
      41             : /** The sfx2::sidebar::ControllerItem is a wrapper around the
      42             :     SfxControllerItem that becomes necessary to allow objects (think
      43             :     sidebar panels) to receive state changes without having one
      44             :     SfxControllerItem per supported item as base class (which is not
      45             :     possible in C++ anyway).
      46             : 
      47             :     It also gives access to the label and icon of a slot/command.
      48             : */
      49             : class SFX2_DLLPUBLIC ControllerItem
      50             :     : public SfxControllerItem
      51             : {
      52             : public:
      53           0 :     class SFX2_DLLPUBLIC ItemUpdateReceiverInterface
      54             :     {
      55             :     public:
      56             :         virtual void NotifyItemUpdate(
      57             :             const sal_uInt16 nSId,
      58             :             const SfxItemState eState,
      59             :             const SfxPoolItem* pState,
      60             :             const bool bIsEnabled) = 0;
      61             :         virtual ~ItemUpdateReceiverInterface();
      62             :     };
      63             : 
      64             :     /** This is the preferred constructor that allows the created
      65             :         controller item to return non-empty values for GetLable() and
      66             :         GetIcon() calls.
      67             :     */
      68             :     ControllerItem (
      69             :         const sal_uInt16 nSlotId,
      70             :         SfxBindings &rBindings,
      71             :         ItemUpdateReceiverInterface& rItemUpdateReceiver,
      72             :         const ::rtl::OUString& rsCommandName,
      73             :         const cssu::Reference<css::frame::XFrame>& rxFrame);
      74             : 
      75             :     /** This is the simpler constructor variant that still exists for
      76             :         compatibility resons.  Note that GetLabel() and GetIcon() will
      77             :         return empty strings/images.
      78             :     */
      79             :     ControllerItem (
      80             :         const sal_uInt16 nId,
      81             :         SfxBindings &rBindings,
      82             :         ItemUpdateReceiverInterface& rItemUpdateReceiver);
      83             : 
      84             :     virtual ~ControllerItem();
      85             : 
      86             :     /** Returns </TRUE> when the slot/command has not been disabled.
      87             :         Changes of this state are notified via the
      88             :         ItemUpdateReceiverInterface::NotifyContextChang() method.
      89             :     */
      90             :     bool IsEnabled (const SfxItemState eState) const;
      91             : 
      92             :     /** Force the controller item to call its NotifyItemUpdate
      93             :         callback with up-to-date data.
      94             :     */
      95             :     void RequestUpdate (void);
      96             : 
      97             :     /** Return the label for the command.  It contains the keyboard
      98             :         accelerator when one exists.
      99             :     */
     100             :     ::rtl::OUString GetLabel (void) const;
     101             : 
     102             :     /** Return the extended help text for the command.
     103             :         Returns an empty string when the UNO command name is not available.
     104             :     */
     105             :     ::rtl::OUString GetHelpText (void) const;
     106             : 
     107             :     /** Return the icon for the command.
     108             :     */
     109             :     Image GetIcon (void) const;
     110             : 
     111             :     /** Convenience method for setting all relevant properties for the
     112             :         slot/command represented by the called object at the given tool
     113             :         box.
     114             :     */
     115             :     void SetupToolBoxItem (ToolBox& rToolBox, const sal_uInt16 nIndex);
     116             : 
     117             :     /** Do not call.  Used by local class only.  Should be a member of
     118             :         a local and hidden interface.
     119             :     */
     120             :     void NotifyFrameContextChange (void);
     121             :     /** Do not call.  Used by local class only.  Should be a member of
     122             :         a local and hidden interface.
     123             :     */
     124             :     void ResetFrame (void);
     125             : 
     126             : protected:
     127             : 
     128             :     virtual void StateChanged (sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState) SAL_OVERRIDE;
     129             : 
     130             : private:
     131             :     ItemUpdateReceiverInterface& mrItemUpdateReceiver;
     132             :     cssu::Reference<css::frame::XFrame> mxFrame;
     133             :     cssu::Reference<css::lang::XComponent> mxFrameActionListener;
     134             :     const ::rtl::OUString msCommandName;
     135             : 
     136             :     void SetupCommandURL (const sal_Char* sCommandName);
     137             : };
     138             : 
     139             : } } // end of namespace sfx2::sidebar
     140             : 
     141             : #endif
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10