LCOV - code coverage report
Current view: top level - libreoffice/sfx2/inc/sfx2 - mnuitem.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 7 42.9 %
Date: 2012-12-17 Functions: 1 3 33.3 %
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             : class SFX2_DLLPUBLIC SfxMenuControl: public SfxControllerItem
      37             : {
      38             :     String                  aTitle;
      39             :     SfxVirtualMenu*         pOwnMenu;
      40             :     SfxVirtualMenu*         pSubMenu;
      41             :     sal_Bool                    b_ShowStrings;
      42             : 
      43             : public:
      44             :                             SfxMenuControl();
      45             :                             SfxMenuControl( sal_Bool bShowStrings );
      46             :                             SfxMenuControl( sal_uInt16, SfxBindings&);
      47             : 
      48             :     static SfxMenuControl*  CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings );
      49             :     static void             RegisterControl( sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL );
      50             : 
      51             :                             ~SfxMenuControl();
      52             : 
      53             :         using SfxControllerItem::Bind;
      54             :     void                    Bind( SfxVirtualMenu* pOwnMenu, sal_uInt16 nId,
      55             :                                   const String& rTitle, SfxBindings& rBindings );
      56             :     void                    Bind( SfxVirtualMenu* pOwnMenu, sal_uInt16 nId,
      57             :                                   SfxVirtualMenu& rSubMenu,
      58             :                                   const String& rTitle, SfxBindings& rBindings );
      59             : 
      60             :     String                  GetTitle() const;
      61             :     SfxVirtualMenu*         GetPopupMenu() const;
      62             :     virtual PopupMenu*      GetPopup() const;
      63             : 
      64             :     virtual void            StateChanged( sal_uInt16 nSID, SfxItemState eState,
      65             :                                           const SfxPoolItem* pState );
      66             : 
      67             :     static SfxMenuControl*    CreateControl( sal_uInt16 nId, Menu &, SfxBindings & );
      68             :     static SfxUnoMenuControl* CreateControl( const String&, sal_uInt16, Menu&, const String& sItemText, SfxBindings&, SfxVirtualMenu* );
      69             :     static void             RegisterMenuControl(SfxModule*, SfxMenuCtrlFactory*);
      70             : 
      71             : };
      72             : 
      73             : class SfxUnoMenuControl : public SfxMenuControl
      74             : {
      75             :     SfxUnoControllerItem*   pUnoCtrl;
      76             : public:
      77             :                             SfxUnoMenuControl( const String&, sal_uInt16 nId, Menu&,
      78             :                                                const String&,
      79             :                                                 SfxBindings&, SfxVirtualMenu* );
      80             :                             ~SfxUnoMenuControl();
      81             : };
      82             : 
      83             : typedef SfxMenuControl* (*SfxMenuControlCtor)( sal_uInt16 nId, Menu &, SfxBindings & );
      84             : 
      85             : struct SfxMenuCtrlFactory
      86             : {
      87             :     SfxMenuControlCtor  pCtor;
      88             :     TypeId              nTypeId;
      89             :     sal_uInt16              nSlotId;
      90             : 
      91          18 :     SfxMenuCtrlFactory( SfxMenuControlCtor pTheCtor,
      92             :             TypeId nTheTypeId, sal_uInt16 nTheSlotId ):
      93             :         pCtor(pTheCtor),
      94             :         nTypeId(nTheTypeId),
      95          18 :         nSlotId(nTheSlotId)
      96          18 :     {}
      97             : };
      98             : 
      99           0 : inline String SfxMenuControl::GetTitle() const
     100             : {
     101           0 :     return aTitle;
     102             : }
     103             : 
     104           0 : inline SfxVirtualMenu* SfxMenuControl::GetPopupMenu() const
     105             : {
     106           0 :     return pSubMenu;
     107             : }
     108             : 
     109             : #define SFX_DECL_MENU_CONTROL() \
     110             :         static SfxMenuControl* CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ); \
     111             :         static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL)
     112             : 
     113             : #define SFX_IMPL_MENU_CONTROL(Class, nItemClass) \
     114             :         SfxMenuControl* Class::CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ) \
     115             :                { return new Class(nId, rMenu, rBindings); } \
     116             :         void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
     117             :                { SfxMenuControl::RegisterMenuControl( pMod, new SfxMenuCtrlFactory( \
     118             :                     Class::CreateImpl, TYPE(nItemClass), nSlotId ) ); }
     119             : #endif
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10