LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/svtools - contextmenuhelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 4 0.0 %
Date: 2013-07-09 Functions: 0 1 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             : 
      20             : #ifndef INCLUDED_SVTOOLS_CONTEXTMENUHELPER_HXX
      21             : #define INCLUDED_SVTOOLS_CONTEXTMENUHELPER_HXX
      22             : 
      23             : #include <com/sun/star/frame/XFrame.hpp>
      24             : #include <com/sun/star/awt/XPopupMenu.hpp>
      25             : #include <com/sun/star/util/XURLTransformer.hpp>
      26             : #include <com/sun/star/ui/XImageManager.hpp>
      27             : #include <com/sun/star/container/XNameAccess.hpp>
      28             : 
      29             : #include <rtl/ustring.hxx>
      30             : #include <cppuhelper/weak.hxx>
      31             : #include <vcl/menu.hxx>
      32             : #include "svtools/svtdllapi.h"
      33             : 
      34             : namespace svt
      35             : {
      36             : 
      37             : /**
      38             :     Context menu helper class.
      39             : 
      40             :     Fills images and labels for a provided popup menu or
      41             :     com.sun.star.awt.XPopupMenu.
      42             : 
      43             :     PRECONDITION:
      44             :     All commands must be set via SetItemCommand and are part
      45             :     of the configuration files
      46             :     (see org.openoffice.Office.UI.[Module]Commands.xcu)
      47             : */
      48             : struct ExecuteInfo;
      49             : class SVT_DLLPUBLIC ContextMenuHelper
      50             : {
      51             :     public:
      52             :         // create context menu helper
      53             :         // ARGS: xFrame = frame defines the context of the context menu
      54             :         //       bAutoRefresh = specifies that the context will be constant or not
      55             :         ContextMenuHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, bool bAutoRefresh=true );
      56             :         ~ContextMenuHelper();
      57             : 
      58             :         // methods to complete a popup menu (set images, labels, enable/disable states)
      59             :         // ATTENTION: The item ID's must be unique for the whole popup (inclusive the sub menus!)
      60             :         void completeAndExecute( const Point& aPos, PopupMenu& aPopupMenu );
      61             :         void completeAndExecute( const Point& aPos, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >& xPopupMenu );
      62             : 
      63             :     private:
      64             :         // asynchronous link to prevent destruction while on stack
      65             :         DECL_STATIC_LINK( ContextMenuHelper, ExecuteHdl_Impl, ExecuteInfo* );
      66             : 
      67             :         // no copy-ctor and operator=
      68             :         ContextMenuHelper( const ContextMenuHelper& );
      69             :         const ContextMenuHelper& operator=( const ContextMenuHelper& );
      70             : 
      71             :         // show context menu and dispatch command automatically
      72             :         void            executePopupMenu( const Point& aPos, PopupMenu* pMenu );
      73             : 
      74             :         // fill image and label for every menu item on the provided menu
      75             :         void            completeMenuProperties( Menu* pMenu );
      76             : 
      77             :         // dispatch provided command
      78             :         bool            dispatchCommand( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const OUString& aCommandURL );
      79             : 
      80             : 
      81             :         // methods to retrieve a single command URL dependent value from a
      82             :         // ui configuratin manager
      83             :         Image           getImageFromCommandURL( const OUString& aCmdURL ) const;
      84             :         OUString   getLabelFromCommandURL( const OUString& aCmdURL ) const;
      85             : 
      86             :         // creates an association between current module/controller bound to the
      87             :         // provided frame and their ui configuration managers.
      88             :         bool            associateUIConfigurationManagers();
      89             : 
      90             :         // resets associations to create associations again on-demand.
      91             :         // Useful for implementations which recycle frames. Normal
      92             :         // implementations can profit from caching and should set
      93             :         // auto refresh on ctor to false (default).
      94           0 :         void            resetAssociations()
      95             :         {
      96           0 :             if ( m_bAutoRefresh )
      97           0 :                 m_bUICfgMgrAssociated = false;
      98           0 :         }
      99             : 
     100             :         ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XFrame >         m_xWeakFrame;
     101             :         OUString                                                                 m_aModuleIdentifier;
     102             :         OUString                                                                 m_aSelf;
     103             :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >     m_xURLTransformer;
     104             :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >       m_aDefaultArgs;
     105             :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager >         m_xDocImageMgr;
     106             :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager >         m_xModuleImageMgr;
     107             :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xUICommandLabels;
     108             :         bool                                                                            m_bAutoRefresh;
     109             :         bool                                                                            m_bUICfgMgrAssociated;
     110             : };
     111             : 
     112             : } // namespace svt
     113             : 
     114             : #endif // INCLUDED_SVTOOLS_CONTEXTMENUHELPER_HXX
     115             : 
     116             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10