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

Generated by: LCOV version 1.10