summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/Library_fwe.mk1
-rw-r--r--framework/source/fwe/classes/bmkmenu.cxx204
-rw-r--r--framework/source/fwe/xml/menuconfiguration.cxx13
-rw-r--r--framework/source/uielement/menubarmanager.cxx1
-rw-r--r--framework/source/uielement/newmenucontroller.cxx59
5 files changed, 34 insertions, 244 deletions
diff --git a/framework/Library_fwe.mk b/framework/Library_fwe.mk
index 848e52c71d58..9b10e161299d 100644
--- a/framework/Library_fwe.mk
+++ b/framework/Library_fwe.mk
@@ -57,7 +57,6 @@ $(eval $(call gb_Library_add_exception_objects,fwe,\
framework/source/fwe/classes/actiontriggerseparatorpropertyset \
framework/source/fwe/classes/addonmenu \
framework/source/fwe/classes/addonsoptions \
- framework/source/fwe/classes/bmkmenu \
framework/source/fwe/classes/framelistanalyzer \
framework/source/fwe/classes/fwkresid \
framework/source/fwe/classes/imagewrapper \
diff --git a/framework/source/fwe/classes/bmkmenu.cxx b/framework/source/fwe/classes/bmkmenu.cxx
deleted file mode 100644
index 4b316a73c325..000000000000
--- a/framework/source/fwe/classes/bmkmenu.cxx
+++ /dev/null
@@ -1,204 +0,0 @@
-/* -*- 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 <limits.h>
-
-#include <framework/bmkmenu.hxx>
-#include <general.h>
-#include <framework/menuconfiguration.hxx>
-
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/util/URL.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <comphelper/processfactory.hxx>
-#include <com/sun/star/util/XURLTransformer.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/util/DateTime.hpp>
-
-#include <vcl/svapp.hxx>
-#include <vcl/settings.hxx>
-#include <vcl/commandinfoprovider.hxx>
-#include <unotools/dynamicmenuoptions.hxx>
-#include <svtools/menuoptions.hxx>
-
-using namespace ::comphelper;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::util;
-using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::beans;
-
-namespace framework
-{
-
-void GetMenuEntry(
- Sequence< PropertyValue >& aDynamicMenuEntry,
- OUString& rTitle,
- OUString& rURL,
- OUString& rFrame,
- OUString& rImageId );
-
-class BmkMenu_Impl
-{
- private:
- static sal_uInt16 m_nMID;
-
- public:
- bool m_bInitialized;
-
- BmkMenu_Impl();
- ~BmkMenu_Impl();
-
- static sal_uInt16 GetMID();
-};
-
-sal_uInt16 BmkMenu_Impl::m_nMID = BMKMENU_ITEMID_START;
-
-BmkMenu_Impl::BmkMenu_Impl() :
- m_bInitialized(false)
-{
-}
-
-BmkMenu_Impl::~BmkMenu_Impl()
-{
-}
-
-sal_uInt16 BmkMenu_Impl::GetMID()
-{
- m_nMID++;
- if( !m_nMID )
- m_nMID = BMKMENU_ITEMID_START;
- return m_nMID;
-}
-
-BmkMenu::BmkMenu( Reference< XFrame >& xFrame, BmkMenu::BmkMenuType nType )
- :AddonMenu(xFrame)
- ,m_nType( nType )
-{
- _pImp = new BmkMenu_Impl();
- Initialize();
-}
-
-BmkMenu::~BmkMenu()
-{
- delete _pImp;
-}
-
-void BmkMenu::Initialize()
-{
- SAL_INFO( "fwk", "framework (cd100003) ::BmkMenu::Initialize" );
-
- if( _pImp->m_bInitialized )
- return;
-
- _pImp->m_bInitialized = true;
-
- Sequence< Sequence< PropertyValue > > aDynamicMenuEntries;
-
- if ( m_nType == BmkMenu::BMK_NEWMENU )
- aDynamicMenuEntries = SvtDynamicMenuOptions().GetMenu( E_NEWMENU );
- else if ( m_nType == BmkMenu::BMK_WIZARDMENU )
- aDynamicMenuEntries = SvtDynamicMenuOptions().GetMenu( E_WIZARDMENU );
-
- const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
- bool bShowMenuImages = rSettings.GetUseImagesInMenus();
-
- OUString aTitle;
- OUString aURL;
- OUString aTargetFrame;
- OUString aImageId;
-
- sal_uInt32 i, nCount = aDynamicMenuEntries.getLength();
- for ( i = 0; i < nCount; ++i )
- {
- GetMenuEntry( aDynamicMenuEntries[i], aTitle, aURL, aTargetFrame, aImageId );
-
- if ( aTitle.isEmpty() && aURL.isEmpty() )
- continue;
-
- if ( aURL == "private:separator" )
- InsertSeparator();
- else
- {
- sal_uInt16 nId = CreateMenuId();
-
- if ( bShowMenuImages )
- {
- bool bImageSet = false;
-
- if ( !aImageId.isEmpty() )
- {
- Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand( aImageId, false, m_xFrame );
- if ( !!aImage )
- {
- bImageSet = true;
- InsertItem( nId, aTitle, aImage );
- }
- }
-
- if ( !bImageSet )
- {
- Image aImage = vcl::CommandInfoProvider::Instance().GetImageForCommand( aURL, false, m_xFrame );
- if ( !aImage )
- InsertItem( nId, aTitle );
- else
- InsertItem( nId, aTitle, aImage );
- }
- }
- else
- InsertItem( nId, aTitle );
-
- sal_uIntPtr nAttributePtr = MenuAttributes::CreateAttribute(aTargetFrame, aImageId);
- SetUserValue(nId, nAttributePtr, MenuAttributes::ReleaseAttribute);
-
- SetItemCommand( nId, aURL );
- }
- }
-}
-
-sal_uInt16 BmkMenu::CreateMenuId()
-{
- return BmkMenu_Impl::GetMID();
-}
-
-void GetMenuEntry
-(
- Sequence< PropertyValue >& aDynamicMenuEntry,
- OUString& rTitle,
- OUString& rURL,
- OUString& rFrame,
- OUString& rImageId
-)
-{
- for ( int i = 0; i < aDynamicMenuEntry.getLength(); i++ )
- {
- if ( aDynamicMenuEntry[i].Name == DYNAMICMENU_PROPERTYNAME_URL )
- aDynamicMenuEntry[i].Value >>= rURL;
- else if ( aDynamicMenuEntry[i].Name == DYNAMICMENU_PROPERTYNAME_TITLE )
- aDynamicMenuEntry[i].Value >>= rTitle;
- else if ( aDynamicMenuEntry[i].Name == DYNAMICMENU_PROPERTYNAME_IMAGEIDENTIFIER )
- aDynamicMenuEntry[i].Value >>= rImageId;
- else if ( aDynamicMenuEntry[i].Name == DYNAMICMENU_PROPERTYNAME_TARGETNAME )
- aDynamicMenuEntry[i].Value >>= rFrame;
- }
-}
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/fwe/xml/menuconfiguration.cxx b/framework/source/fwe/xml/menuconfiguration.cxx
index 1cec54b2b557..fcda2ed2f1d4 100644
--- a/framework/source/fwe/xml/menuconfiguration.cxx
+++ b/framework/source/fwe/xml/menuconfiguration.cxx
@@ -19,7 +19,6 @@
#include <framework/menuconfiguration.hxx>
-#include <framework/bmkmenu.hxx>
#include <framework/addonmenu.hxx>
#include <xml/menudocumenthandler.hxx>
#include <xml/saxnamespacefilter.hxx>
@@ -100,18 +99,6 @@ Reference< XIndexAccess > MenuConfiguration::CreateMenuBarConfigurationFromXML(
}
}
-PopupMenu* MenuConfiguration::CreateBookmarkMenu(css::uno::Reference<css::frame::XFrame >& rFrame, const OUString& aURL)
- throw (css::lang::WrappedTargetException,
- css::uno::RuntimeException)
-{
- if ( aURL == BOOKMARK_NEWMENU )
- return new BmkMenu( rFrame, BmkMenu::BMK_NEWMENU );
- else if ( aURL == BOOKMARK_WIZARDMENU )
- return new BmkMenu( rFrame, BmkMenu::BMK_WIZARDMENU );
- else
- return nullptr;
-}
-
void MenuConfiguration::StoreMenuBarConfigurationToXML(
Reference< XIndexAccess >& rMenuBarConfiguration,
Reference< XOutputStream >& rOutputStream, bool bIsMenuBar )
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index 77f5be659475..d7408886cd90 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -19,7 +19,6 @@
#include <uielement/menubarmanager.hxx>
#include <framework/menuconfiguration.hxx>
-#include <framework/bmkmenu.hxx>
#include <framework/addonmenu.hxx>
#include <framework/addonsoptions.hxx>
#include <classes/fwkresid.hxx>
diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx
index 5e848bb57ea9..c48e66a055fb 100644
--- a/framework/source/uielement/newmenucontroller.cxx
+++ b/framework/source/uielement/newmenucontroller.cxx
@@ -22,8 +22,6 @@
#include "services.h"
#include <classes/resource.hrc>
#include <classes/fwkresid.hxx>
-#include <framework/bmkmenu.hxx>
-#include <framework/menuconfiguration.hxx>
#include <com/sun/star/awt/XDevice.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
@@ -43,6 +41,7 @@
#include <svtools/acceleratorexecute.hxx>
#include <svtools/imagemgr.hxx>
#include <tools/urlobj.hxx>
+#include <unotools/dynamicmenuoptions.hxx>
#include <unotools/moduleoptions.hxx>
#include <osl/mutex.hxx>
#include <memory>
@@ -331,9 +330,6 @@ void NewMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopup
if ( pVCLPopupMenu )
{
- MenuConfiguration aMenuCfg( m_xContext );
- std::unique_ptr<BmkMenu> pSubMenu;
-
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
URL aTargetURL;
aTargetURL.Complete = rtl::OUString::createFromAscii(m_bNewMenu ? aSlotNewDocDirect : aSlotAutoPilot);
@@ -341,31 +337,44 @@ void NewMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopup
Reference< XDispatch > xMenuItemDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
if(xMenuItemDispatch == nullptr)
return;
- if ( m_bNewMenu )
- pSubMenu.reset(static_cast<BmkMenu*>(aMenuCfg.CreateBookmarkMenu( m_xFrame, BOOKMARK_NEWMENU )));
- else
- pSubMenu.reset(static_cast<BmkMenu*>(aMenuCfg.CreateBookmarkMenu( m_xFrame, BOOKMARK_WIZARDMENU )));
- // copy entries as we have to use the provided popup menu
- *pVCLPopupMenu = *pSubMenu;
+ css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aDynamicMenuEntries =
+ SvtDynamicMenuOptions().GetMenu( m_bNewMenu ? E_NEWMENU : E_WIZARDMENU );
- Image aImage;
+ OUString aTitle;
+ OUString aURL;
+ OUString aTargetFrame;
+ OUString aImageId;
+ sal_uInt16 nItemId = 1;
- // retrieve additional parameters from bookmark menu and
- // store it in a unordered_map.
- for ( sal_uInt16 i = 0; i < pSubMenu->GetItemCount(); i++ )
+ for ( const auto& aDynamicMenuEntry : aDynamicMenuEntries )
{
- sal_uInt16 nItemId = pSubMenu->GetItemId( sal::static_int_cast<sal_uInt16>( i ) );
- if (( nItemId != 0 ) &&
- ( pSubMenu->GetItemType( nItemId ) != MenuItemType::SEPARATOR ))
+ for ( const auto& aProperty : aDynamicMenuEntry )
{
- sal_uLong nAttributePtr = pSubMenu->GetUserValue(nItemId);
- if (nAttributePtr)
- {
- MenuAttributes* pAttributes = reinterpret_cast<MenuAttributes *>(nAttributePtr);
- pAttributes->acquire();
- pVCLPopupMenu->SetUserValue(nItemId, nAttributePtr, MenuAttributes::ReleaseAttribute);
- }
+ if ( aProperty.Name == DYNAMICMENU_PROPERTYNAME_URL )
+ aProperty.Value >>= aURL;
+ else if ( aProperty.Name == DYNAMICMENU_PROPERTYNAME_TITLE )
+ aProperty.Value >>= aTitle;
+ else if ( aProperty.Name == DYNAMICMENU_PROPERTYNAME_IMAGEIDENTIFIER )
+ aProperty.Value >>= aImageId;
+ else if ( aProperty.Name == DYNAMICMENU_PROPERTYNAME_TARGETNAME )
+ aProperty.Value >>= aTargetFrame;
+ }
+
+ if ( aTitle.isEmpty() && aURL.isEmpty() )
+ continue;
+
+ if ( aURL == "private:separator" )
+ pVCLPopupMenu->InsertSeparator();
+ else
+ {
+ pVCLPopupMenu->InsertItem( nItemId, aTitle );
+ pVCLPopupMenu->SetItemCommand( nItemId, aURL );
+
+ sal_uIntPtr nAttributePtr = MenuAttributes::CreateAttribute( aTargetFrame, aImageId );
+ pVCLPopupMenu->SetUserValue( nItemId, nAttributePtr, MenuAttributes::ReleaseAttribute );
+
+ nItemId++;
}
}