LCOV - code coverage report
Current view: top level - include/sfx2 - mnuitem.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 3 7 42.9 %
Date: 2015-06-13 12:38:46 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 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             : #include <tools/link.hxx>
      29             : 
      30             : class SfxVirtualMenu;
      31             : class SfxBindings;
      32             : class SfxModule;
      33             : class Menu;
      34             : class PopupMenu;
      35             : class SfxUnoMenuControl;
      36             : class SfxUnoControllerItem;
      37             : struct SfxMenuCtrlFactory;
      38             : 
      39             : class SFX2_DLLPUBLIC SfxMenuControl: public SfxControllerItem
      40             : {
      41             :     OUString                aTitle;
      42             :     SfxVirtualMenu*         pOwnMenu;
      43             :     SfxVirtualMenu*         pSubMenu;
      44             :     bool                    b_ShowStrings;
      45             : 
      46             : public:
      47             :                             SfxMenuControl();
      48             :                             SfxMenuControl( 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             :                     virtual ~SfxMenuControl();
      55             : 
      56             :     using SfxControllerItem::Bind;
      57             :     void                    Bind( SfxVirtualMenu* pOwnMenu, sal_uInt16 nId,
      58             :                                   const OUString& rTitle, SfxBindings& rBindings );
      59             :     void                    Bind( SfxVirtualMenu* pOwnMenu, sal_uInt16 nId,
      60             :                                   SfxVirtualMenu& rSubMenu,
      61             :                                   const OUString& rTitle, SfxBindings& rBindings );
      62             : 
      63             :     OUString                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 ) SAL_OVERRIDE;
      69             : 
      70             :     static SfxMenuControl*    CreateControl( sal_uInt16 nId, Menu &, SfxBindings & );
      71             :     static SfxUnoMenuControl* CreateControl( const OUString&, sal_uInt16, Menu&, const OUString& 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 OUString&, sal_uInt16 nId, Menu&,
      81             :                                                const OUString&,
      82             :                                                 SfxBindings&, SfxVirtualMenu* );
      83             :                             virtual ~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         500 :     SfxMenuCtrlFactory( SfxMenuControlCtor pTheCtor,
      95             :             TypeId nTheTypeId, sal_uInt16 nTheSlotId ):
      96             :         pCtor(pTheCtor),
      97             :         nTypeId(nTheTypeId),
      98         500 :         nSlotId(nTheSlotId)
      99         500 :     {}
     100             : };
     101             : 
     102           0 : inline OUString 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             : #endif
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11