LCOV - code coverage report
Current view: top level - include/sfx2 - mnuitem.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 8 0.0 %
Date: 2014-04-14 Functions: 0 5 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_MNUITEM_HXX
      20             : #define INCLUDED_SFX2_MNUITEM_HXX
      21             : 
      22             : #include <com/sun/star/frame/XDispatch.hpp>
      23             : #include <com/sun/star/util/URL.hpp>
      24             : #include <rtl/ustring.hxx>
      25             : #include <sal/config.h>
      26             : #include <sfx2/ctrlitem.hxx>
      27             : #include <sfx2/dllapi.h>
      28             : 
      29             : class SfxVirtualMenu;
      30             : class SfxBindings;
      31             : class SfxModule;
      32             : class Menu;
      33             : class PopupMenu;
      34             : class SfxUnoMenuControl;
      35             : class SfxUnoControllerItem;
      36             : struct SfxMenuCtrlFactory;
      37             : 
      38             : class SFX2_DLLPUBLIC SfxMenuControl: public SfxControllerItem
      39             : {
      40             :     OUString                aTitle;
      41             :     SfxVirtualMenu*         pOwnMenu;
      42             :     SfxVirtualMenu*         pSubMenu;
      43             :     bool                    b_ShowStrings;
      44             : 
      45             : public:
      46             :                             SfxMenuControl();
      47             :                             SfxMenuControl( bool bShowStrings );
      48             :                             SfxMenuControl( sal_uInt16, SfxBindings&);
      49             : 
      50             :     static SfxMenuControl*  CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings );
      51             :     static void             RegisterControl( sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL );
      52             : 
      53             :                             virtual ~SfxMenuControl();
      54             : 
      55             :         using SfxControllerItem::Bind;
      56             :     void                    Bind( SfxVirtualMenu* pOwnMenu, sal_uInt16 nId,
      57             :                                   const OUString& rTitle, SfxBindings& rBindings );
      58             :     void                    Bind( SfxVirtualMenu* pOwnMenu, sal_uInt16 nId,
      59             :                                   SfxVirtualMenu& rSubMenu,
      60             :                                   const OUString& rTitle, SfxBindings& rBindings );
      61             : 
      62             :     OUString                GetTitle() const;
      63             :     SfxVirtualMenu*         GetPopupMenu() const;
      64             :     virtual PopupMenu*      GetPopup() const;
      65             : 
      66             :     virtual void            StateChanged( sal_uInt16 nSID, SfxItemState eState,
      67             :                                           const SfxPoolItem* pState ) SAL_OVERRIDE;
      68             : 
      69             :     static SfxMenuControl*    CreateControl( sal_uInt16 nId, Menu &, SfxBindings & );
      70             :     static SfxUnoMenuControl* CreateControl( const OUString&, sal_uInt16, Menu&, const OUString& sItemText, SfxBindings&, SfxVirtualMenu* );
      71             :     static void             RegisterMenuControl(SfxModule*, SfxMenuCtrlFactory*);
      72             : 
      73             : };
      74             : 
      75             : class SfxUnoMenuControl : public SfxMenuControl
      76             : {
      77             :     SfxUnoControllerItem*   pUnoCtrl;
      78             : public:
      79             :                             SfxUnoMenuControl( const OUString&, sal_uInt16 nId, Menu&,
      80             :                                                const OUString&,
      81             :                                                 SfxBindings&, SfxVirtualMenu* );
      82             :                             virtual ~SfxUnoMenuControl();
      83             : };
      84             : 
      85             : typedef SfxMenuControl* (*SfxMenuControlCtor)( sal_uInt16 nId, Menu &, SfxBindings & );
      86             : 
      87             : struct SfxMenuCtrlFactory
      88             : {
      89             :     SfxMenuControlCtor  pCtor;
      90             :     TypeId              nTypeId;
      91             :     sal_uInt16              nSlotId;
      92             : 
      93           0 :     SfxMenuCtrlFactory( SfxMenuControlCtor pTheCtor,
      94             :             TypeId nTheTypeId, sal_uInt16 nTheSlotId ):
      95             :         pCtor(pTheCtor),
      96             :         nTypeId(nTheTypeId),
      97           0 :         nSlotId(nTheSlotId)
      98           0 :     {}
      99             : };
     100             : 
     101           0 : inline OUString SfxMenuControl::GetTitle() const
     102             : {
     103           0 :     return aTitle;
     104             : }
     105             : 
     106           0 : inline SfxVirtualMenu* SfxMenuControl::GetPopupMenu() const
     107             : {
     108           0 :     return pSubMenu;
     109             : }
     110             : 
     111             : #define SFX_DECL_MENU_CONTROL() \
     112             :         static SfxMenuControl* CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ); \
     113             :         static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL)
     114             : 
     115             : #define SFX_IMPL_MENU_CONTROL(Class, nItemClass) \
     116             :         SfxMenuControl* Class::CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ) \
     117             :                { return new Class(nId, rMenu, rBindings); } \
     118             :         void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
     119             :                { SfxMenuControl::RegisterMenuControl( pMod, new SfxMenuCtrlFactory( \
     120             :                     Class::CreateImpl, TYPE(nItemClass), nSlotId ) ); }
     121             : 
     122             : class SfxAppMenuControl_Impl : public SfxMenuControl
     123             : {
     124             :     PopupMenu*  pMenu;
     125             :     OUString    m_sIconTheme;
     126             :     bool        m_bShowMenuImages;
     127             : 
     128             : protected:
     129             :     DECL_LINK( Activate, Menu * ); // Needed to support high contrast images
     130             : 
     131             : public:
     132             :     SFX_DECL_MENU_CONTROL();
     133             :     SfxAppMenuControl_Impl( sal_uInt16 nPos, Menu& rMenu, SfxBindings& rBindings );
     134             :     virtual ~SfxAppMenuControl_Impl();
     135             : 
     136           0 :     struct ExecuteInfo
     137             :     {
     138             :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >     xDispatch;
     139             :         ::com::sun::star::util::URL                                                aTargetURL;
     140             :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >  aArgs;
     141             :     };
     142             : 
     143             :     DECL_STATIC_LINK( SfxAppMenuControl_Impl, ExecuteHdl_Impl, ExecuteInfo* );
     144             : };
     145             : 
     146             : #endif
     147             : 
     148             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10