Kaydet (Commit) 21b92f38 authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky Kaydeden (comit) Caolán McNamara

MenuDispatcher::m_pMenuManager is always nullptr

... as shown by 7da15deb.
Which means that MenuManager is unused, and MenuDispatcher
does nothing useful.

Change-Id: Ic85619531054a573d971d38b52609e1cbcaf780c
Reviewed-on: https://gerrit.libreoffice.org/23117Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 70c8d278
...@@ -433,8 +433,7 @@ bool ConstantFunction::VisitFunctionDecl(const FunctionDecl * pFunctionDecl) { ...@@ -433,8 +433,7 @@ bool ConstantFunction::VisitFunctionDecl(const FunctionDecl * pFunctionDecl) {
return true; return true;
} }
// LINK callback which supplies a return value which means something // LINK callback which supplies a return value which means something
if (aFunctionName == "framework::MenuManager::Highlight" if (aFunctionName == "framework::MenuBarManager::Highlight") {
|| aFunctionName == "framework::MenuBarManager::Highlight") {
return true; return true;
} }
if (aFunctionName == "sc::AlignedAllocator::operator!=") { if (aFunctionName == "sc::AlignedAllocator::operator!=") {
......
...@@ -68,14 +68,12 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\ ...@@ -68,14 +68,12 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
framework/source/accelerators/storageholder \ framework/source/accelerators/storageholder \
framework/source/classes/framecontainer \ framework/source/classes/framecontainer \
framework/source/classes/fwktabwindow \ framework/source/classes/fwktabwindow \
framework/source/classes/menumanager \
framework/source/classes/taskcreator \ framework/source/classes/taskcreator \
framework/source/dispatch/closedispatcher \ framework/source/dispatch/closedispatcher \
framework/source/dispatch/dispatchinformationprovider \ framework/source/dispatch/dispatchinformationprovider \
framework/source/dispatch/dispatchprovider \ framework/source/dispatch/dispatchprovider \
framework/source/dispatch/interceptionhelper \ framework/source/dispatch/interceptionhelper \
framework/source/dispatch/loaddispatcher \ framework/source/dispatch/loaddispatcher \
framework/source/dispatch/menudispatcher \
framework/source/dispatch/startmoduledispatcher \ framework/source/dispatch/startmoduledispatcher \
framework/source/dispatch/windowcommanddispatch \ framework/source/dispatch/windowcommanddispatch \
framework/source/helper/dockingareadefaultacceptor \ framework/source/helper/dockingareadefaultacceptor \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_MENUMANAGER_HXX
#define INCLUDED_FRAMEWORK_INC_CLASSES_MENUMANAGER_HXX
#include <vector>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/FeatureStateEvent.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <rtl/ustring.hxx>
#include <vcl/menu.hxx>
#include <vcl/accel.hxx>
#include <cppuhelper/implbase.hxx>
namespace com { namespace sun { namespace star { namespace uno {
class XComponentContext;
} } } }
namespace framework
{
class BmkMenu;
class AddonMenu;
class AddonPopupMenu;
class MenuManager : public ::cppu::WeakImplHelper< css::frame::XStatusListener >
{
public:
MenuManager(
const css::uno::Reference< css::uno::XComponentContext >& rxContext,
css::uno::Reference< css::frame::XFrame >& rFrame,
Menu* pMenu,
bool bDelete,
bool bDeleteChildren );
virtual ~MenuManager();
// XStatusListener
virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) override;
// XEventListener
virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception ) override;
DECL_LINK_TYPED( Select, Menu *, bool );
Menu* GetMenu() const { return m_pVCLMenu; }
void RemoveListener();
static void UpdateSpecialWindowMenu( Menu* pMenu ,const css::uno::Reference< css::uno::XComponentContext >& xContext);
static void FillMenuImages(
css::uno::Reference< css::frame::XFrame >& xFrame,
Menu* _pMenu,
bool bShowMenuImages
);
protected:
DECL_LINK_TYPED(Highlight, Menu *, bool);
DECL_LINK_TYPED( Activate, Menu *, bool );
DECL_LINK_TYPED( Deactivate, Menu *, bool );
private:
void UpdateSpecialFileMenu( Menu* pMenu );
void ClearMenuDispatch(const css::lang::EventObject& Source = css::lang::EventObject(),bool _bRemoveOnly = true);
void SetHdl();
void AddMenu(PopupMenu* _pPopupMenu,const OUString& _sItemCommand,sal_uInt16 _nItemId,bool _bDelete,bool _bDeleteChildren);
sal_uInt16 FillItemCommand(OUString& _rItemCommand, Menu* _pMenu,sal_uInt16 _nIndex) const;
struct MenuItemHandler
{
MenuItemHandler( sal_uInt16 aItemId, MenuManager* pManager, css::uno::Reference< css::frame::XDispatch >& rDispatch ) :
nItemId( aItemId ), pSubMenuManager( pManager ), xMenuItemDispatch( rDispatch ) {}
sal_uInt16 nItemId;
OUString aTargetFrame;
OUString aMenuItemURL;
OUString aFilter;
OUString aPassword;
OUString aTitle;
MenuManager* pSubMenuManager;
css::uno::Reference< css::frame::XDispatch > xMenuItemDispatch;
};
void CreatePicklistArguments(
css::uno::Sequence< css::beans::PropertyValue >& aArgsList,
const MenuItemHandler* );
MenuItemHandler* GetMenuItemHandler( sal_uInt16 nItemId );
bool m_bInitialized;
bool m_bDeleteMenu;
bool m_bDeleteChildren;
bool m_bActive;
bool m_bIsBookmarkMenu;
bool m_bShowMenuImages;
OUString m_aMenuItemCommand;
Menu* m_pVCLMenu;
css::uno::Reference< css::frame::XFrame > m_xFrame;
::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer;
};
} // namespace
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -48,7 +48,6 @@ namespace framework{ ...@@ -48,7 +48,6 @@ namespace framework{
enum EDispatchHelper enum EDispatchHelper
{ {
E_DEFAULTDISPATCHER , E_DEFAULTDISPATCHER ,
E_MENUDISPATCHER ,
E_CREATEDISPATCHER , E_CREATEDISPATCHER ,
E_BLANKDISPATCHER , E_BLANKDISPATCHER ,
E_SELFDISPATCHER , E_SELFDISPATCHER ,
...@@ -83,8 +82,6 @@ class DispatchProvider : private TransactionBase , ...@@ -83,8 +82,6 @@ class DispatchProvider : private TransactionBase ,
css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::uno::XComponentContext > m_xContext;
/// weakreference to owner frame (Don't use a hard reference. Owner can't delete us then!) /// weakreference to owner frame (Don't use a hard reference. Owner can't delete us then!)
css::uno::WeakReference< css::frame::XFrame > m_xFrame; css::uno::WeakReference< css::frame::XFrame > m_xFrame;
/// different dispatcher to handle special dispatch calls, protocols or URLs (they will be created on demand.)
css::uno::Reference< css::frame::XDispatch > m_xMenuDispatcher;
/// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols /// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols
HandlerCache m_aProtocolHandlerCache; HandlerCache m_aProtocolHandlerCache;
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_MENUDISPATCHER_HXX
#define INCLUDED_FRAMEWORK_INC_DISPATCH_MENUDISPATCHER_HXX
#include <classes/taskcreator.hxx>
#include <macros/xinterface.hxx>
#include <macros/xtypeprovider.hxx>
#include <classes/menumanager.hxx>
#include <general.h>
#include <stdtypes.h>
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/util/URL.hpp>
#include <com/sun/star/frame/DispatchDescriptor.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/frame/XStatusListener.hpp>
#include <com/sun/star/frame/XFrameLoader.hpp>
#include <com/sun/star/frame/XLoadEventListener.hpp>
#include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/frame/FeatureStateEvent.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XFrameActionListener.hpp>
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/weakref.hxx>
#include <cppuhelper/interfacecontainer.h>
namespace framework{
typedef cppu::OMultiTypeInterfaceContainerHelperVar<OUString>
IMPL_ListenerHashContainer;
/*-************************************************************************************************************
@short helper for desktop only(!) to create new tasks on demand for dispatches
@descr Use this class as member only! Never use it as baseclass.
XInterface will be ambigous and we hold a weakcss::uno::Reference to our OWNER - not to our SUPERCLASS!
@implements XInterface
XDispatch
XLoadEventListener
XFrameActionListener
XEventListener
@base OWeakObject
@devstatus ready to use
*//*-*************************************************************************************************************/
class MenuDispatcher : public ::cppu::WeakImplHelper<
css::frame::XDispatch ,
css::frame::XFrameActionListener >
{
// public methods
public:
// constructor / destructor
/*-****************************************************************************************************
@short standard ctor
@descr This initializes a new instance of the class with needed information for work.
@seealso using at owner
@param "rxContext" , css::uno::Reference to servicemanager for creation of new services
@param "xOwner" , css::uno::Reference to our owner, the Desktop!!!
*//*-*****************************************************************************************************/
MenuDispatcher( const css::uno::Reference< css::uno::XComponentContext >& rxContext ,
const css::uno::Reference< css::frame::XFrame >& xOwner );
// XDispatch
/*-****************************************************************************************************
@short dispatch URL with arguments
@descr Every dispatch create a new task. If load of URL failed task will deleted automatically!
@param "aURL" , URL to dispatch.
@param "seqArguments" , list of optional arguments.
*//*-*****************************************************************************************************/
virtual void SAL_CALL dispatch( const css::util::URL& aURL ,
const css::uno::Sequence< css::beans::PropertyValue >& seqProperties ) throw( css::uno::RuntimeException, std::exception ) override;
/*-****************************************************************************************************
@short add listener for state events
@descr You can add a listener to get information about status of dispatch: OK or Failed.
@seealso method loadFinished()
@seealso method loadCancelled()
@param "xControl" , css::uno::Reference to a valid listener for state events.
@param "aURL" , URL about listener will be informed, if something occurred.
*//*-*****************************************************************************************************/
virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl,
const css::util::URL& aURL ) throw( css::uno::RuntimeException, std::exception ) override;
/*-****************************************************************************************************
@short remove listener for state events
@descr You can remove a listener if information of dispatch isn't important for you any longer.
@seealso method loadFinished()
@seealso method loadCancelled()
@param "xControl" , css::uno::Reference to a valid listener.
@param "aURL" , URL on which listener has registered.
*//*-*****************************************************************************************************/
virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl,
const css::util::URL& aURL ) throw( css::uno::RuntimeException, std::exception ) override;
// XFrameActionListener
virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) throw ( css::uno::RuntimeException, std::exception ) override;
// XEventListener
/*-****************************************************************************************************
@short dispose current instance
@descr If service helper isn't required any longer call this method to release all used resources.
@param "aEvent", information about source of this event.
*//*-*****************************************************************************************************/
void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException, std::exception ) override;
// protected methods
protected:
/*-****************************************************************************************************
@short standard destructor
@descr This method destruct an instance of this class and clear some member.
This method is protected, because its not allowed to use an instance of this class as a member!
You MUST use a pointer.
*//*-*****************************************************************************************************/
virtual ~MenuDispatcher();
private:
/*-****************************************************************************************************
*//*-*****************************************************************************************************/
bool impl_clearMenuBar();
/*-****************************************************************************************************
*//*-*****************************************************************************************************/
void impl_setAccelerators( Menu* pMenu, const Accelerator& aAccel );
// variables
// (should be private everyway!)
private:
css::uno::WeakReference< css::frame::XFrame > m_xOwnerWeak; /// css::uno::WeakReference to owner (Don't use a hard css::uno::Reference. Owner can't delete us then!)
css::uno::Reference< css::uno::XComponentContext > m_xContext; /// factory shared with our owner to create new services!
osl::Mutex m_mutex;
IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs
bool m_bAlreadyDisposed; /// Protection against multiple disposing calls.
bool m_bActivateListener; /// dispatcher is listener for frame activation
MenuManager* m_pMenuManager; /// menu manager controlling menu dispatches
}; // class MenuDispatcher
} // namespace framework
#endif // INCLUDED_FRAMEWORK_INC_DISPATCH_MENUDISPATCHER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -30,7 +30,6 @@ namespace framework{ ...@@ -30,7 +30,6 @@ namespace framework{
#define SPECIALTARGET_BLANK "_blank" // Create a new task. #define SPECIALTARGET_BLANK "_blank" // Create a new task.
#define SPECIALTARGET_DEFAULT "_default" // Create a new task or recycle an existing one #define SPECIALTARGET_DEFAULT "_default" // Create a new task or recycle an existing one
#define SPECIALTARGET_BEAMER "_beamer" // special frame in hierarchy #define SPECIALTARGET_BEAMER "_beamer" // special frame in hierarchy
#define SPECIALTARGET_MENUBAR "_menubar" // special target for menubars
#define SPECIALTARGET_HELPTASK "OFFICE_HELP_TASK" // special name for our help task #define SPECIALTARGET_HELPTASK "OFFICE_HELP_TASK" // special name for our help task
} // namespace framework } // namespace framework
......
...@@ -188,6 +188,8 @@ class MenuBarManager : public css::frame::XStatusListener , ...@@ -188,6 +188,8 @@ class MenuBarManager : public css::frame::XStatusListener ,
void RetrieveShortcuts( std::vector< MenuItemHandler* >& aMenuShortCuts ); void RetrieveShortcuts( std::vector< MenuItemHandler* >& aMenuShortCuts );
void CheckAndAddMenuExtension( Menu* pMenu ); void CheckAndAddMenuExtension( Menu* pMenu );
static void UpdateSpecialWindowMenu( Menu* pMenu, const css::uno::Reference< css::uno::XComponentContext >& xContext );
static void FillMenuImages( css::uno::Reference< css::frame::XFrame >& xFrame, Menu* _pMenu, bool bShowMenuImages );
static void impl_RetrieveShortcutsFromConfiguration( const css::uno::Reference< css::ui::XAcceleratorConfiguration >& rAccelCfg, static void impl_RetrieveShortcutsFromConfiguration( const css::uno::Reference< css::ui::XAcceleratorConfiguration >& rAccelCfg,
const css::uno::Sequence< OUString >& rCommands, const css::uno::Sequence< OUString >& rCommands,
std::vector< MenuItemHandler* >& aMenuShortCuts ); std::vector< MenuItemHandler* >& aMenuShortCuts );
......
This diff is collapsed.
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <loadenv/loadenv.hxx> #include <loadenv/loadenv.hxx>
#include <dispatch/loaddispatcher.hxx> #include <dispatch/loaddispatcher.hxx>
#include <dispatch/closedispatcher.hxx> #include <dispatch/closedispatcher.hxx>
#include <dispatch/menudispatcher.hxx>
#include <dispatch/startmoduledispatcher.hxx> #include <dispatch/startmoduledispatcher.hxx>
#include <pattern/window.hxx> #include <pattern/window.hxx>
...@@ -33,6 +32,7 @@ ...@@ -33,6 +32,7 @@
#include <targets.h> #include <targets.h>
#include <general.h> #include <general.h>
#include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp>
#include <com/sun/star/uno/Exception.hpp> #include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/ucb/XContentProviderManager.hpp> #include <com/sun/star/ucb/XContentProviderManager.hpp>
...@@ -167,7 +167,6 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryDeskt ...@@ -167,7 +167,6 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryDeskt
// ignore wrong requests which are not supported // ignore wrong requests which are not supported
if ( if (
(sTargetFrameName==SPECIALTARGET_MENUBAR ) || // valid for frame dispatches - not for desktop
(sTargetFrameName==SPECIALTARGET_PARENT ) || // we have no parent by definition (sTargetFrameName==SPECIALTARGET_PARENT ) || // we have no parent by definition
(sTargetFrameName==SPECIALTARGET_BEAMER ) // beamer frames are allowed as child of tasks only - (sTargetFrameName==SPECIALTARGET_BEAMER ) // beamer frames are allowed as child of tasks only -
// and they exist more than ones. We have no idea which our sub tasks is the right one // and they exist more than ones. We have no idea which our sub tasks is the right one
...@@ -271,15 +270,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryFrame ...@@ -271,15 +270,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryFrame
xDispatcher = xParent->queryDispatch(aURL, sTargetName, 0); // it's a special target - ignore search flags xDispatcher = xParent->queryDispatch(aURL, sTargetName, 0); // it's a special target - ignore search flags
} }
// I.II) "_menubar" // I.II) "_beamer"
// Special mode on frame or task to receive the local menu. Not supported by findFrame()
else if (sTargetName==SPECIALTARGET_MENUBAR)
{
xDispatcher = implts_getOrCreateDispatchHelper( E_MENUDISPATCHER, xFrame );
}
// I.IV) "_beamer"
// Special sub frame of a top frame only. Search or create it. ... OK it's currently a little bit HACKI. // Special sub frame of a top frame only. Search or create it. ... OK it's currently a little bit HACKI.
// Only the sfx (means the controller) can create it. // Only the sfx (means the controller) can create it.
...@@ -300,7 +291,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryFrame ...@@ -300,7 +291,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryFrame
} }
} }
// I.V) "_parent" // I.IV) "_parent"
// Our parent frame (if it exist) should handle this URL. // Our parent frame (if it exist) should handle this URL.
else if (sTargetName==SPECIALTARGET_PARENT) else if (sTargetName==SPECIALTARGET_PARENT)
...@@ -311,7 +302,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryFrame ...@@ -311,7 +302,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryFrame
xDispatcher = xParent->queryDispatch(aURL, SPECIALTARGET_SELF, 0); xDispatcher = xParent->queryDispatch(aURL, SPECIALTARGET_SELF, 0);
} }
// I.VI) "_top" // I.V) "_top"
// This request must be forwarded to any parent frame, till we reach a top frame. // This request must be forwarded to any parent frame, till we reach a top frame.
// If no parent exist, we can handle itself. // If no parent exist, we can handle itself.
...@@ -334,7 +325,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryFrame ...@@ -334,7 +325,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryFrame
} }
} }
// I.VII) "_self", "" // I.VI) "_self", ""
// Our owner frame should handle this URL. But we can't do it for all of them. // Our owner frame should handle this URL. But we can't do it for all of them.
// So we ask the internal setted controller first. If he disagree we try to find a registered // So we ask the internal setted controller first. If he disagree we try to find a registered
// protocol handler. If this failed too - we check for a loadable content and in case of true // protocol handler. If this failed too - we check for a loadable content and in case of true
...@@ -394,7 +385,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryFrame ...@@ -394,7 +385,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_queryFrame
} }
} }
// I.VI) no further special handlings exist // I.VII) no further special handlings exist
// Now we have to search for the right target frame by calling findFrame() - but should provide our code // Now we have to search for the right target frame by calling findFrame() - but should provide our code
// against creation of a new task if no frame could be found. // against creation of a new task if no frame could be found.
// I said it before - it's allowed for dispatch() only. // I said it before - it's allowed for dispatch() only.
...@@ -535,20 +526,6 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat ...@@ -535,20 +526,6 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat
switch (eHelper) switch (eHelper)
{ {
case E_MENUDISPATCHER :
{
// Attention: Such menue dispatcher must be a singleton for this frame - means our owner frame.
// Otherwhise he can make some trouble.
SolarMutexGuard g;
if ( ! m_xMenuDispatcher.is() )
{
MenuDispatcher* pDispatcher = new MenuDispatcher( m_xContext, xOwner );
m_xMenuDispatcher.set( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
}
xDispatchHelper = m_xMenuDispatcher;
}
break;
case E_CREATEDISPATCHER : case E_CREATEDISPATCHER :
{ {
LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, sTarget, nSearchFlags); LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, sTarget, nSearchFlags);
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <dispatch/menudispatcher.hxx>
#include <general.h>
#include <framework/menuconfiguration.hxx>
#include <framework/addonmenu.hxx>
#include <services.h>
#include <com/sun/star/frame/FrameSearchFlag.hpp>
#include <com/sun/star/awt/WindowAttribute.hpp>
#include <com/sun/star/awt/WindowDescriptor.hpp>
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/awt/XWindowPeer.hpp>
#include <com/sun/star/beans/UnknownPropertyException.hpp>
#include <com/sun/star/lang/WrappedTargetException.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <vcl/window.hxx>
#include <vcl/syswin.hxx>
#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
#include <tools/rcid.h>
#include <osl/mutex.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <ucbhelper/content.hxx>
namespace framework{
using namespace ::com::sun::star;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::util;
using namespace ::cppu;
// constructor
MenuDispatcher::MenuDispatcher( const uno::Reference< XComponentContext >& xContext ,
const uno::Reference< XFrame >& xOwner )
: m_xOwnerWeak ( xOwner )
, m_xContext ( xContext )
, m_aListenerContainer ( m_mutex )
, m_bAlreadyDisposed ( false )
, m_bActivateListener ( false )
, m_pMenuManager ( nullptr )
{
// Safe impossible cases
// We need valid information about our owner for work.
SAL_WARN_IF( !( xContext.is() && xOwner.is() ), "fwk", "MenuDispatcher::MenuDispatcher()\nInvalid parameter detected!" );
m_bActivateListener = true;
xOwner->addFrameActionListener( uno::Reference< XFrameActionListener >( static_cast<OWeakObject *>(this), UNO_QUERY ));
}
// destructor
MenuDispatcher::~MenuDispatcher()
{
// Warn programmer if he forgot to dispose this instance.
// We must release all our references ...
// and a dtor isn't the best place to do that!
}
// XDispatch
void SAL_CALL MenuDispatcher::dispatch( const URL& /*aURL*/ ,
const Sequence< PropertyValue >& /*seqProperties*/ ) throw( RuntimeException, std::exception )
{
}
// XDispatch
void SAL_CALL MenuDispatcher::addStatusListener( const uno::Reference< XStatusListener >& xControl,
const URL& aURL ) throw( RuntimeException, std::exception )
{
SolarMutexGuard g;
// Safe impossible cases
// Method not defined for all incoming parameter
SAL_WARN_IF( !xControl.is() || aURL.Complete.isEmpty(), "fwk", "MenuDispatcher::addStatusListener(): Invalid parameter detected." );
// Add listener to container.
m_aListenerContainer.addInterface( aURL.Complete, xControl );
}
// XDispatch
void SAL_CALL MenuDispatcher::removeStatusListener( const uno::Reference< XStatusListener >& xControl,
const URL& aURL ) throw( RuntimeException, std::exception )
{
SolarMutexGuard g;
// Safe impossible cases
// Method not defined for all incoming parameter
SAL_WARN_IF( !xControl.is() || aURL.Complete.isEmpty(), "fwk", "MenuDispatcher::removeStatusListener(): Invalid parameter detected." );
// Add listener to container.
m_aListenerContainer.removeInterface( aURL.Complete, xControl );
}
// XFrameActionListener
void SAL_CALL MenuDispatcher::frameAction( const FrameActionEvent& aEvent ) throw ( RuntimeException, std::exception )
{
SolarMutexResettableGuard aGuard;
if ( m_pMenuManager && aEvent.Action == FrameAction_FRAME_UI_ACTIVATED )
{
MenuBar* pMenuBar = static_cast<MenuBar *>(m_pMenuManager->GetMenu());
uno::Reference< XFrame > xFrame( m_xOwnerWeak.get(), UNO_QUERY );
aGuard.clear();
if ( xFrame.is() && pMenuBar )
{
uno::Reference< css::awt::XWindow >xContainerWindow = xFrame->getContainerWindow();
aGuard.reset();
{
vcl::Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
while ( pWindow && !pWindow->IsSystemWindow() )
pWindow = pWindow->GetParent();
if ( pWindow )
{
SystemWindow* pSysWindow = static_cast<SystemWindow *>(pWindow);
pSysWindow->SetMenuBar( pMenuBar );
}
}
}
}
else if ( m_pMenuManager && aEvent.Action == css::frame::FrameAction_COMPONENT_DETACHING )
{
if ( m_pMenuManager )
impl_clearMenuBar();
}
}
// XEventListener
void SAL_CALL MenuDispatcher::disposing( const EventObject& ) throw( RuntimeException, std::exception )
{
SolarMutexGuard g;
// Safe impossible cases
SAL_WARN_IF( m_bAlreadyDisposed, "fwk", "MenuDispatcher::disposing(): Object already disposed .. don't call it again!" );
if( !m_bAlreadyDisposed )
{
m_bAlreadyDisposed = true;
if ( m_bActivateListener )
{
uno::Reference< XFrame > xFrame( m_xOwnerWeak.get(), UNO_QUERY );
if ( xFrame.is() )
{
xFrame->removeFrameActionListener( uno::Reference< XFrameActionListener >( static_cast<OWeakObject *>(this), UNO_QUERY ));
m_bActivateListener = false;
if ( m_pMenuManager )
{
EventObject aEventObj;
aEventObj.Source = xFrame;
m_pMenuManager->disposing( aEventObj );
}
}
}
// Forget our factory.
m_xContext.clear();
// Remove our menu from system window if it is still there!
if ( m_pMenuManager )
impl_clearMenuBar();
}
}
void MenuDispatcher::impl_setAccelerators( Menu* pMenu, const Accelerator& aAccel )
{
for ( sal_uInt16 nPos = 0; nPos < pMenu->GetItemCount(); ++nPos )
{
sal_uInt16 nId = pMenu->GetItemId(nPos);
::PopupMenu* pPopup = pMenu->GetPopupMenu(nId);
if ( pPopup )
impl_setAccelerators( static_cast<Menu *>(pPopup), aAccel );
else if ( nId && !pMenu->GetPopupMenu(nId))
{
vcl::KeyCode aCode = aAccel.GetKeyCode( nId );
if ( aCode.GetCode() )
pMenu->SetAccelKey( nId, aCode );
}
}
}
bool MenuDispatcher::impl_clearMenuBar()
{
uno::Reference< XFrame > xFrame( m_xOwnerWeak.get(), UNO_QUERY );
if ( xFrame.is() )
{
uno::Reference< css::awt::XWindow >xContainerWindow = xFrame->getContainerWindow();
vcl::Window* pWindow = nullptr;
SolarMutexGuard aSolarGuard;
{
pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
while ( pWindow && !pWindow->IsSystemWindow() )
pWindow = pWindow->GetParent();
}
if ( pWindow )
{
SystemWindow* pSysWindow = static_cast<SystemWindow *>(pWindow);
if ( m_pMenuManager )
{
// remove old menu from our system window if it was set before
if ( m_pMenuManager->GetMenu() == static_cast<Menu *>(pSysWindow->GetMenuBar()) )
pSysWindow->SetMenuBar( nullptr );
// remove listener before we destruct ourself, so we cannot be called back afterwards
m_pMenuManager->RemoveListener();
(static_cast< css::uno::XInterface* >(static_cast<OWeakObject*>(m_pMenuManager)))->release();
m_pMenuManager = nullptr;
}
return true;
}
}
return false;
}
} // namespace framework
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -48,7 +48,6 @@ class TargetHelper ...@@ -48,7 +48,6 @@ class TargetHelper
E_BLANK , E_BLANK ,
E_DEFAULT , E_DEFAULT ,
E_BEAMER , E_BEAMER ,
E_MENUBAR ,
E_HELPAGENT , E_HELPAGENT ,
E_HELPTASK E_HELPTASK
}; };
......
...@@ -47,9 +47,6 @@ bool TargetHelper::matchSpecialTarget(const OUString& sCheckTarget , ...@@ -47,9 +47,6 @@ bool TargetHelper::matchSpecialTarget(const OUString& sCheckTarget ,
case E_BEAMER : case E_BEAMER :
return sCheckTarget == SPECIALTARGET_BEAMER; return sCheckTarget == SPECIALTARGET_BEAMER;
case E_MENUBAR :
return sCheckTarget == SPECIALTARGET_MENUBAR;
case E_HELPTASK : case E_HELPTASK :
return sCheckTarget == SPECIALTARGET_HELPTASK; return sCheckTarget == SPECIALTARGET_HELPTASK;
default: default:
......
...@@ -907,7 +907,6 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS ...@@ -907,7 +907,6 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS
if ( if (
(sTargetFrameName==SPECIALTARGET_DEFAULT ) || // valid for dispatches - not for findFrame()! (sTargetFrameName==SPECIALTARGET_DEFAULT ) || // valid for dispatches - not for findFrame()!
(sTargetFrameName==SPECIALTARGET_MENUBAR ) || // valid for dispatches - not for findFrame()!
(sTargetFrameName==SPECIALTARGET_PARENT ) || // we have no parent by definition (sTargetFrameName==SPECIALTARGET_PARENT ) || // we have no parent by definition
(sTargetFrameName==SPECIALTARGET_BEAMER ) // beamer frames are allowed as child of tasks only - (sTargetFrameName==SPECIALTARGET_BEAMER ) // beamer frames are allowed as child of tasks only -
// and they exist more than ones. We have no idea which our sub tasks is the right one // and they exist more than ones. We have no idea which our sub tasks is the right one
......
...@@ -945,7 +945,7 @@ OUString SAL_CALL Frame::getName() throw( css::uno::RuntimeException, std::excep ...@@ -945,7 +945,7 @@ OUString SAL_CALL Frame::getName() throw( css::uno::RuntimeException, std::excep
@descr This name is used to find target of findFrame() or queryDispatch() calls. @descr This name is used to find target of findFrame() or queryDispatch() calls.
@attention Special names like "_blank", "_self" aren't allowed... @attention Special names like "_blank", "_self" aren't allowed...
"_beamer" or "_menubar" excepts this rule! "_beamer" excepts this rule!
@seealso method getName() @seealso method getName()
...@@ -997,10 +997,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Frame::findFrame( const OUStr ...@@ -997,10 +997,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Frame::findFrame( const OUStr
// in following code again and again. If we do not so -wrong // in following code again and again. If we do not so -wrong
// search results can occur! // search results can occur!
if ( if ( sTargetFrameName == SPECIALTARGET_DEFAULT ) // valid for dispatches - not for findFrame()!
(sTargetFrameName==SPECIALTARGET_DEFAULT ) || // valid for dispatches - not for findFrame()!
(sTargetFrameName==SPECIALTARGET_MENUBAR ) // valid for dispatches - not for findFrame()!
)
{ {
return nullptr; return nullptr;
} }
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <framework/addonmenu.hxx> #include <framework/addonmenu.hxx>
#include <framework/addonsoptions.hxx> #include <framework/addonsoptions.hxx>
#include <classes/fwkresid.hxx> #include <classes/fwkresid.hxx>
#include <classes/menumanager.hxx>
#include <helper/mischelper.hxx> #include <helper/mischelper.hxx>
#include <framework/menuextensionsupplier.hxx> #include <framework/menuextensionsupplier.hxx>
#include <classes/resource.hrc> #include <classes/resource.hrc>
...@@ -764,7 +763,7 @@ IMPL_LINK_TYPED( MenuBarManager, Activate, Menu *, pMenu, bool ) ...@@ -764,7 +763,7 @@ IMPL_LINK_TYPED( MenuBarManager, Activate, Menu *, pMenu, bool )
OUString aMenuCommand( m_aMenuItemCommand ); OUString aMenuCommand( m_aMenuItemCommand );
if ( m_aMenuItemCommand == aSpecialWindowMenu || m_aMenuItemCommand == aSlotSpecialWindowMenu || aMenuCommand == aSpecialWindowCommand ) if ( m_aMenuItemCommand == aSpecialWindowMenu || m_aMenuItemCommand == aSlotSpecialWindowMenu || aMenuCommand == aSpecialWindowCommand )
MenuManager::UpdateSpecialWindowMenu( pMenu, m_xContext ); UpdateSpecialWindowMenu( pMenu, m_xContext );
// Check if some modes have changed so we have to update our menu images // Check if some modes have changed so we have to update our menu images
OUString sIconTheme = SvtMiscOptions().GetIconTheme(); OUString sIconTheme = SvtMiscOptions().GetIconTheme();
...@@ -776,7 +775,7 @@ IMPL_LINK_TYPED( MenuBarManager, Activate, Menu *, pMenu, bool ) ...@@ -776,7 +775,7 @@ IMPL_LINK_TYPED( MenuBarManager, Activate, Menu *, pMenu, bool )
m_bShowMenuImages = bShowMenuImages; m_bShowMenuImages = bShowMenuImages;
m_bRetrieveImages = false; m_bRetrieveImages = false;
m_sIconTheme = sIconTheme; m_sIconTheme = sIconTheme;
MenuManager::FillMenuImages( m_xFrame, pMenu, bShowMenuImages ); FillMenuImages( m_xFrame, pMenu, bShowMenuImages );
} }
// Try to map commands to labels // Try to map commands to labels
...@@ -1981,6 +1980,126 @@ void MenuBarManager::SetHdl() ...@@ -1981,6 +1980,126 @@ void MenuBarManager::SetHdl()
m_xURLTransformer.set( URLTransformer::create( m_xContext) ); m_xURLTransformer.set( URLTransformer::create( m_xContext) );
} }
void MenuBarManager::UpdateSpecialWindowMenu( Menu* pMenu,const Reference< XComponentContext >& xContext )
{
// update window list
::std::vector< OUString > aNewWindowListVector;
Reference< XDesktop2 > xDesktop = css::frame::Desktop::create( xContext );
sal_uInt16 nActiveItemId = 0;
sal_uInt16 nItemId = START_ITEMID_WINDOWLIST;
Reference< XFrame > xCurrentFrame = xDesktop->getCurrentFrame();
Reference< XIndexAccess > xList( xDesktop->getFrames(), UNO_QUERY );
sal_Int32 nFrameCount = xList->getCount();
aNewWindowListVector.reserve(nFrameCount);
for (sal_Int32 i=0; i<nFrameCount; ++i )
{
Reference< XFrame > xFrame;
xList->getByIndex(i) >>= xFrame;
if (xFrame.is())
{
if ( xFrame == xCurrentFrame )
nActiveItemId = nItemId;
vcl::Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
if ( pWin && pWin->IsVisible() )
{
aNewWindowListVector.push_back( pWin->GetText() );
++nItemId;
}
}
}
{
SolarMutexGuard g;
int nItemCount = pMenu->GetItemCount();
if ( nItemCount > 0 )
{
// remove all old window list entries from menu
sal_uInt16 nPos = pMenu->GetItemPos( START_ITEMID_WINDOWLIST );
for ( sal_uInt16 n = nPos; n < pMenu->GetItemCount(); )
pMenu->RemoveItem( n );
if ( pMenu->GetItemType( pMenu->GetItemCount()-1 ) == MenuItemType::SEPARATOR )
pMenu->RemoveItem( pMenu->GetItemCount()-1 );
}
if ( !aNewWindowListVector.empty() )
{
// append new window list entries to menu
pMenu->InsertSeparator();
nItemId = START_ITEMID_WINDOWLIST;
const sal_uInt32 nCount = aNewWindowListVector.size();
for ( sal_uInt32 i = 0; i < nCount; i++ )
{
pMenu->InsertItem( nItemId, aNewWindowListVector.at( i ), MenuItemBits::RADIOCHECK );
if ( nItemId == nActiveItemId )
pMenu->CheckItem( nItemId );
++nItemId;
}
}
}
}
void MenuBarManager::FillMenuImages(Reference< XFrame >& _xFrame, Menu* _pMenu,bool bShowMenuImages)
{
AddonsOptions aAddonOptions;
for ( sal_uInt16 nPos = 0; nPos < _pMenu->GetItemCount(); nPos++ )
{
sal_uInt16 nId = _pMenu->GetItemId( nPos );
if ( _pMenu->GetItemType( nPos ) != MenuItemType::SEPARATOR )
{
bool bTmpShowMenuImages( bShowMenuImages );
// overwrite the show icons on menu option?
if (!bTmpShowMenuImages)
{
MenuItemBits nBits = _pMenu->GetItemBits( nId );
bTmpShowMenuImages = ( ( nBits & MenuItemBits::ICON ) == MenuItemBits::ICON );
}
if ( bTmpShowMenuImages )
{
bool bImageSet = false;
OUString aImageId;
::framework::MenuAttributes* pMenuAttributes =
reinterpret_cast< ::framework::MenuAttributes*>(_pMenu->GetUserValue( nId ));
if ( pMenuAttributes )
aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes
if ( !aImageId.isEmpty() )
{
Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aImageId, false, _xFrame );
if ( !!aImage )
{
bImageSet = true;
_pMenu->SetItemImage( nId, aImage );
}
}
if ( !bImageSet )
{
OUString aMenuItemCommand = _pMenu->GetItemCommand( nId );
Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand(aMenuItemCommand, false, _xFrame );
if ( !aImage )
aImage = aAddonOptions.GetImageFromURL( aMenuItemCommand, false );
_pMenu->SetItemImage( nId, aImage );
}
}
else
_pMenu->SetItemImage( nId, Image() );
}
}
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -63,7 +63,6 @@ namespace { ...@@ -63,7 +63,6 @@ namespace {
const char FRAME_PROPNAME_LAYOUTMANAGER[] = "LayoutManager"; const char FRAME_PROPNAME_LAYOUTMANAGER[] = "LayoutManager";
const char HID_BACKINGWINDOW[] = "FWK_HID_BACKINGWINDOW"; const char HID_BACKINGWINDOW[] = "FWK_HID_BACKINGWINDOW";
const char SPECIALTARGET_MENUBAR[] = "_menubar";
/** /**
implements the backing component. implements the backing component.
...@@ -589,21 +588,6 @@ void SAL_CALL BackingComp::dispose() ...@@ -589,21 +588,6 @@ void SAL_CALL BackingComp::dispose()
/* SAFE { */ /* SAFE { */
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
// kill the menu
css::util::URL aURL;
aURL.Complete = ".uno:close";
css::uno::Reference< css::util::XURLTransformer > xParser = css::util::URLTransformer::create(m_xContext);
if (xParser.is())
xParser->parseStrict(aURL);
css::uno::Reference< css::frame::XDispatchProvider > xProvider(m_xFrame, css::uno::UNO_QUERY);
if (xProvider.is())
{
css::uno::Reference< css::frame::XDispatch > xDispatch = xProvider->queryDispatch(aURL, SPECIALTARGET_MENUBAR, 0);
if (xDispatch.is())
xDispatch->dispatch(aURL, css::uno::Sequence< css::beans::PropertyValue>());
}
// stop listening at the window // stop listening at the window
if (m_xWindow.is()) if (m_xWindow.is())
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment