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

Generated by: LCOV version 1.10