2011-05-25 08:05:29 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 12:49:02 -05:00
|
|
|
/*
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* A LibreOffice extension to send the menubar structure through DBusMenu
|
|
|
|
*
|
|
|
|
* Copyright 2011 Canonical, Ltd.
|
|
|
|
* Authors:
|
|
|
|
* Alberto Ruiz <alberto.ruiz@codethink.co.uk>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it under
|
|
|
|
* the the GNU Lesser General Public License version 3, as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
|
|
|
|
* SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR PURPOSE. See the applicable
|
|
|
|
* version of the GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-03-31 10:39:38 -05:00
|
|
|
#ifndef __FRAME_HELPER_HXX__
|
|
|
|
#define __FRAME_HELPER_HXX__
|
2011-03-31 12:49:02 -05:00
|
|
|
|
2011-04-27 05:50:43 -05:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
2011-03-31 12:49:02 -05:00
|
|
|
#include <com/sun/star/awt/KeyEvent.hpp>
|
|
|
|
#include <com/sun/star/awt/XMenu.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
2011-04-27 05:50:43 -05:00
|
|
|
#include <com/sun/star/container/XNameAccess.hpp>
|
2011-03-31 12:49:02 -05:00
|
|
|
#include <com/sun/star/frame/FrameAction.hpp>
|
2011-04-27 05:50:43 -05:00
|
|
|
#include <com/sun/star/frame/FrameSearchFlag.hpp>
|
2011-03-31 12:49:02 -05:00
|
|
|
#include <com/sun/star/frame/XDispatchProvider.hpp>
|
2011-04-27 05:50:43 -05:00
|
|
|
#include <com/sun/star/frame/XFrame.hpp>
|
|
|
|
#include <com/sun/star/frame/XFrameActionListener.hpp>
|
|
|
|
#include <com/sun/star/frame/XFramesSupplier.hpp>
|
2011-03-31 12:49:02 -05:00
|
|
|
#include <com/sun/star/frame/XModel.hpp>
|
2011-04-27 05:50:43 -05:00
|
|
|
#include <com/sun/star/frame/XModuleManager.hpp>
|
|
|
|
#include <com/sun/star/frame/XStatusListener.hpp>
|
2011-03-31 12:49:02 -05:00
|
|
|
#include <com/sun/star/lang/EventObject.hpp>
|
2011-04-27 05:50:43 -05:00
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
2011-03-31 12:49:02 -05:00
|
|
|
#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
|
2011-04-27 05:50:43 -05:00
|
|
|
#include <com/sun/star/util/XURLTransformer.hpp>
|
|
|
|
#include <cppuhelper/implbase1.hxx>
|
2011-03-31 12:49:02 -05:00
|
|
|
|
2011-03-31 13:49:27 -05:00
|
|
|
//#pragma GCC diagnostic push
|
2011-04-01 07:06:10 -05:00
|
|
|
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
|
2011-03-31 12:49:02 -05:00
|
|
|
#include <libdbusmenu-glib/server.h>
|
2011-04-01 07:06:10 -05:00
|
|
|
#pragma GCC diagnostic error "-Wignored-qualifiers"
|
2011-03-31 13:49:27 -05:00
|
|
|
//#pragma GCC diagnostic pop
|
2011-03-31 12:49:02 -05:00
|
|
|
#include <libdbusmenu-glib/menuitem.h>
|
|
|
|
|
|
|
|
using com::sun::star::awt::KeyEvent;
|
|
|
|
using com::sun::star::awt::XMenu;
|
|
|
|
using com::sun::star::beans::PropertyValue;
|
|
|
|
using com::sun::star::container::XNameAccess;
|
|
|
|
using com::sun::star::frame::FrameActionEvent;
|
|
|
|
using com::sun::star::frame::XFrame;
|
|
|
|
using com::sun::star::frame::XFramesSupplier;
|
|
|
|
using com::sun::star::frame::XFrameActionListener;
|
|
|
|
using com::sun::star::frame::XStatusListener;
|
|
|
|
using com::sun::star::frame::XDispatchProvider;
|
|
|
|
using com::sun::star::frame::XModuleManager;
|
|
|
|
using com::sun::star::frame::XModel;
|
|
|
|
using com::sun::star::lang::EventObject;
|
|
|
|
using com::sun::star::lang::XMultiServiceFactory;
|
|
|
|
using com::sun::star::lang::XMultiComponentFactory;
|
|
|
|
using com::sun::star::uno::Any;
|
|
|
|
using com::sun::star::uno::Reference;
|
|
|
|
using com::sun::star::uno::Sequence;
|
|
|
|
using com::sun::star::uno::RuntimeException;
|
|
|
|
using com::sun::star::util::XURLTransformer;
|
|
|
|
using com::sun::star::ui::XAcceleratorConfiguration;
|
|
|
|
using rtl::OUString;
|
|
|
|
|
2011-04-27 05:50:43 -05:00
|
|
|
|
|
|
|
namespace framework { namespace lomenubar
|
|
|
|
{
|
|
|
|
class DispatchRegistry;
|
|
|
|
}}
|
|
|
|
|
2011-03-31 12:49:02 -05:00
|
|
|
/* This class is a helper in charge of closing the dbusmenu server when a frame is closed,
|
|
|
|
* and also allows the menuitem callbacks to dispatch commands.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class FrameHelper : public cppu::WeakImplHelper1 < XFrameActionListener >
|
|
|
|
{
|
|
|
|
private:
|
2011-04-27 05:50:43 -05:00
|
|
|
const Reference < XStatusListener > m_xStatusListener;
|
|
|
|
::boost::scoped_ptr< ::framework::lomenubar::DispatchRegistry> m_pDispatchRegistry;
|
|
|
|
const Reference < XMultiServiceFactory > m_xMSF;
|
|
|
|
const Reference < XURLTransformer > m_xTrans;
|
|
|
|
const Reference < XModuleManager> m_xMM;
|
|
|
|
const Reference < XMultiComponentFactory > m_xPCF;
|
|
|
|
const Reference < XFrame > m_xFrame;
|
|
|
|
const Reference < XDispatchProvider > m_xdp;
|
|
|
|
const Sequence < Any > m_args;
|
2011-03-31 13:49:27 -05:00
|
|
|
Reference < XNameAccess > m_xUICommands;
|
|
|
|
DbusmenuServer *m_server;
|
|
|
|
DbusmenuMenuitem *m_root;
|
|
|
|
gboolean m_watcher_set;
|
|
|
|
guint m_watcher;
|
|
|
|
GHashTable *m_commandsInfo;
|
2011-04-27 05:50:43 -05:00
|
|
|
//This variable prevents the helper from being disconnected from the frame
|
|
|
|
//for special cases of component dettaching like print preview
|
2011-03-31 13:49:27 -05:00
|
|
|
gboolean m_blockDetach;
|
2011-03-31 12:49:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
gboolean isSpecialSubmenu (OUString command);
|
|
|
|
|
|
|
|
//This is to build the shortcut database
|
2011-03-31 13:49:27 -05:00
|
|
|
Reference< XAcceleratorConfiguration > m_docAccelConf;
|
|
|
|
Reference< XAcceleratorConfiguration > m_modAccelConf;
|
|
|
|
Reference< XAcceleratorConfiguration > m_globAccelConf;
|
2011-03-31 12:49:02 -05:00
|
|
|
|
|
|
|
void getAcceleratorConfigurations (Reference < XModel >,
|
|
|
|
Reference < XModuleManager>);
|
|
|
|
|
|
|
|
KeyEvent findShortcutForCommand (OUString);
|
|
|
|
|
|
|
|
public:
|
|
|
|
FrameHelper(const Reference< XMultiServiceFactory >&,
|
|
|
|
const Reference< XFrame >&,
|
|
|
|
DbusmenuServer*);
|
|
|
|
|
|
|
|
virtual ~FrameHelper();
|
|
|
|
virtual void SAL_CALL frameAction(const FrameActionEvent& action)
|
|
|
|
throw (RuntimeException);
|
|
|
|
|
|
|
|
virtual void SAL_CALL disposing(const EventObject& aEvent)
|
|
|
|
throw (RuntimeException);
|
|
|
|
|
|
|
|
//Setters
|
|
|
|
void setRootItem (DbusmenuMenuitem *);
|
|
|
|
void setRegistrarWatcher (guint watcher);
|
|
|
|
void setServer (DbusmenuServer *);
|
|
|
|
|
|
|
|
//Getters
|
|
|
|
Reference < XFrame > getFrame ();
|
|
|
|
unsigned long getXID ();
|
|
|
|
GHashTable* getCommandsInfo ();
|
|
|
|
::rtl::OUString getLabelFromCommandURL (::rtl::OUString);
|
|
|
|
|
|
|
|
//Menu Related actions
|
|
|
|
void dispatchCommand (OUString);
|
|
|
|
void rebuildMenu (Reference < XMenu >, DbusmenuMenuitem*);
|
|
|
|
void rebuildMenuFromRoot ();
|
|
|
|
void populateWindowList (DbusmenuMenuitem *);
|
|
|
|
};
|
2011-03-31 10:39:38 -05:00
|
|
|
#endif // __FRAME_HELPER_HXX__
|
2011-05-25 08:05:29 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|