LCOV - code coverage report
Current view: top level - include/svtools - contextmenuhelper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 4 0.0 %
Date: 2015-06-13 12:38:46 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 <cppuhelper/weakref.hxx>
      32             : #include <vcl/menu.hxx>
      33             : #include <svtools/svtdllapi.h>
      34             : 
      35             : namespace svt
      36             : {
      37             : 
      38             : /**
      39             :     Context menu helper class.
      40             : 
      41             :     Fills images and labels for a provided popup menu or
      42             :     com.sun.star.awt.XPopupMenu.
      43             : 
      44             :     PRECONDITION:
      45             :     All commands must be set via SetItemCommand and are part
      46             :     of the configuration files
      47             :     (see org.openoffice.Office.UI.[Module]Commands.xcu)
      48             : */
      49             : struct ExecuteInfo;
      50             : class SVT_DLLPUBLIC ContextMenuHelper
      51             : {
      52             :     public:
      53             :         // create context menu helper
      54             :         // ARGS: xFrame = frame defines the context of the context menu
      55             :         //       bAutoRefresh = specifies that the context will be constant or not
      56             :         ContextMenuHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, bool bAutoRefresh=true );
      57             :         ~ContextMenuHelper();
      58             : 
      59             :         // methods to complete a popup menu (set images, labels, enable/disable states)
      60             :         // ATTENTION: The item ID's must be unique for the whole popup (inclusive the sub menus!)
      61             :         void completeAndExecute( const Point& aPos, PopupMenu& aPopupMenu );
      62             :         void completeAndExecute( const Point& aPos, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >& xPopupMenu );
      63             : 
      64             :     private:
      65             :         // asynchronous link to prevent destruction while on stack
      66             :         DECL_STATIC_LINK( ContextMenuHelper, ExecuteHdl_Impl, ExecuteInfo* );
      67             : 
      68             :         ContextMenuHelper( const ContextMenuHelper& ) SAL_DELETED_FUNCTION;
      69             :         const ContextMenuHelper& operator=( const ContextMenuHelper& ) SAL_DELETED_FUNCTION;
      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_aSelf;
     102             :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >     m_xURLTransformer;
     103             :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >       m_aDefaultArgs;
     104             :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager >         m_xDocImageMgr;
     105             :         ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager >         m_xModuleImageMgr;
     106             :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xUICommandLabels;
     107             :         bool                                                                            m_bAutoRefresh;
     108             :         bool                                                                            m_bUICfgMgrAssociated;
     109             : };
     110             : 
     111             : } // namespace svt
     112             : 
     113             : #endif // INCLUDED_SVTOOLS_CONTEXTMENUHELPER_HXX
     114             : 
     115             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11