2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-12 17:21:24 +00:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2013-10-23 19:18:54 +02:00
|
|
|
#ifndef INCLUDED_FRAMEWORK_ADDONMENU_HXX
|
|
|
|
#define INCLUDED_FRAMEWORK_ADDONMENU_HXX
|
2002-10-11 13:15:41 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/frame/XFrame.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
2003-04-04 16:11:47 +00:00
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
2014-05-16 12:48:54 +00:00
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
2003-04-04 16:11:47 +00:00
|
|
|
|
2002-10-11 13:15:41 +00:00
|
|
|
#include <vcl/menu.hxx>
|
2010-04-19 19:05:02 +02:00
|
|
|
#include <framework/fwedllapi.h>
|
2002-10-11 13:15:41 +00:00
|
|
|
|
2007-07-10 14:05:16 +00:00
|
|
|
#define ADDONMENU_ITEMID_START 2000
|
|
|
|
#define ADDONMENU_ITEMID_END 3000
|
2002-10-11 13:15:41 +00:00
|
|
|
|
|
|
|
namespace framework
|
|
|
|
{
|
|
|
|
|
2010-04-16 23:01:28 +02:00
|
|
|
class FWE_DLLPUBLIC AddonMenu : public PopupMenu
|
2002-10-11 13:15:41 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-11-05 19:24:42 -07:00
|
|
|
AddonMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
|
2014-04-01 19:18:35 +02:00
|
|
|
virtual ~AddonMenu();
|
2002-10-11 13:15:41 +00:00
|
|
|
|
2009-09-08 04:57:32 +00:00
|
|
|
protected:
|
2007-04-16 15:30:34 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
|
2003-04-04 16:11:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class AddonMenuManager;
|
2010-11-05 19:24:42 -07:00
|
|
|
|
2010-04-16 23:01:28 +02:00
|
|
|
class FWE_DLLPUBLIC AddonPopupMenu : public AddonMenu
|
2003-04-04 16:11:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-04-01 19:18:35 +02:00
|
|
|
virtual ~AddonPopupMenu();
|
2003-04-04 16:11:47 +00:00
|
|
|
|
|
|
|
// Check if command URL string has the unique prefix to identify addon popup menus
|
2014-03-25 16:42:40 +02:00
|
|
|
static bool IsCommandURLPrefix( const OUString& aCmdURL );
|
2002-10-11 13:15:41 +00:00
|
|
|
|
2014-03-25 16:42:40 +02:00
|
|
|
void SetCommandURL( const OUString& aCmdURL ) { m_aCommandURL = aCmdURL; }
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& GetCommandURL() const { return m_aCommandURL; }
|
2002-10-11 13:15:41 +00:00
|
|
|
|
|
|
|
protected:
|
2010-11-05 19:24:42 -07:00
|
|
|
void Initialize( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rAddonPopupMenuDefinition );
|
2002-10-11 13:15:41 +00:00
|
|
|
|
|
|
|
private:
|
2010-11-05 19:24:42 -07:00
|
|
|
AddonPopupMenu( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame );
|
2002-10-11 13:15:41 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString m_aCommandURL;
|
2003-04-04 16:11:47 +00:00
|
|
|
|
2003-12-01 15:07:44 +00:00
|
|
|
friend class AddonMenuManager;
|
2002-10-11 13:15:41 +00:00
|
|
|
};
|
|
|
|
|
2010-04-16 23:01:28 +02:00
|
|
|
class FWE_DLLPUBLIC AddonMenuManager
|
2003-03-25 17:22:13 +00:00
|
|
|
{
|
|
|
|
public:
|
2003-04-04 16:11:47 +00:00
|
|
|
enum MenuType
|
|
|
|
{
|
|
|
|
ADDON_MENU,
|
|
|
|
ADDON_POPUPMENU
|
|
|
|
};
|
2003-03-25 17:22:13 +00:00
|
|
|
|
2014-03-25 16:42:40 +02:00
|
|
|
static bool HasAddonMenuElements();
|
2003-03-25 17:22:13 +00:00
|
|
|
|
2014-03-25 16:42:40 +02:00
|
|
|
static bool IsAddonMenuId( sal_uInt16 nId ) { return (( nId >= ADDONMENU_ITEMID_START ) && ( nId < ADDONMENU_ITEMID_END )); }
|
2003-03-25 17:22:13 +00:00
|
|
|
|
2003-04-04 16:11:47 +00:00
|
|
|
// Check if the context string matches the provided xModel context
|
2014-05-16 12:48:54 +00:00
|
|
|
static bool IsCorrectContext(const OUString& rModuleIdentifier, const OUString& rContext);
|
2003-03-25 17:22:13 +00:00
|
|
|
|
2003-04-04 16:11:47 +00:00
|
|
|
// Factory method to create different Add-On menu types
|
2007-04-16 15:30:34 +00:00
|
|
|
static PopupMenu* CreatePopupMenuType( MenuType eMenuType, const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame );
|
2003-03-25 17:22:13 +00:00
|
|
|
|
2003-04-04 16:11:47 +00:00
|
|
|
// Create the Add-Ons menu
|
2014-05-16 12:48:54 +00:00
|
|
|
static AddonMenu* CreateAddonMenu( const css::uno::Reference< css::frame::XFrame >& rFrame,
|
|
|
|
const css::uno::Reference< css::uno::XComponentContext >& rContext );
|
2003-03-25 17:22:13 +00:00
|
|
|
|
2003-04-04 16:11:47 +00:00
|
|
|
// Merge the Add-Ons help menu items into the given menu bar at a defined pos
|
2014-05-16 12:48:54 +00:00
|
|
|
static void MergeAddonHelpMenu( const css::uno::Reference< css::frame::XFrame >& rFrame,
|
|
|
|
MenuBar* pMergeMenuBar,
|
|
|
|
const css::uno::Reference< css::uno::XComponentContext >& rContext );
|
2003-03-25 17:22:13 +00:00
|
|
|
|
2003-04-04 16:11:47 +00:00
|
|
|
// Merge the addon popup menus into the given menu bar at the provided pos.
|
2014-05-16 12:48:54 +00:00
|
|
|
static void MergeAddonPopupMenus( const css::uno::Reference< css::frame::XFrame >& rFrame,
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 nMergeAtPos,
|
2014-05-16 12:48:54 +00:00
|
|
|
MenuBar* pMergeMenuBar,
|
|
|
|
const css::uno::Reference< css::uno::XComponentContext >& rContext );
|
2003-04-04 16:11:47 +00:00
|
|
|
|
|
|
|
// Returns the next position to insert a menu item/sub menu
|
2010-11-05 10:31:15 +08:00
|
|
|
static sal_uInt16 GetNextPos( sal_uInt16 nPos );
|
2003-04-04 16:11:47 +00:00
|
|
|
|
|
|
|
// Build up the menu item and sub menu into the provided pCurrentMenu. The sub menus should be of type nSubMenuType.
|
|
|
|
static void BuildMenu( PopupMenu* pCurrentMenu,
|
|
|
|
MenuType nSubMenuType,
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 nInsPos,
|
|
|
|
sal_uInt16& nUniqueMenuId,
|
2014-05-14 09:58:40 +02:00
|
|
|
const com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > >& aAddonMenuDefinition,
|
2007-04-16 15:30:34 +00:00
|
|
|
const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
|
2014-05-16 12:48:54 +00:00
|
|
|
const ::rtl::OUString& rModuleIdentifier );
|
2003-04-04 16:11:47 +00:00
|
|
|
|
|
|
|
// Retrieve the menu entry property values from a sequence
|
|
|
|
static void GetMenuEntry( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rAddonMenuEntry,
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString& rTitle,
|
|
|
|
OUString& rURL,
|
|
|
|
OUString& rTarget,
|
|
|
|
OUString& rImageId,
|
|
|
|
OUString& rContext,
|
2003-04-04 16:11:47 +00:00
|
|
|
com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > >& rAddonSubMenu );
|
2003-03-25 17:22:13 +00:00
|
|
|
};
|
|
|
|
|
2002-10-11 13:15:41 +00:00
|
|
|
} // namespace framework
|
|
|
|
|
2013-10-23 19:18:54 +02:00
|
|
|
#endif // INCLUDED_FRAMEWORK_ADDONMENU_HXX
|
2010-10-27 13:11:31 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|