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

Generated by: LCOV version 1.10