[Libreoffice-commits] core.git: framework/Library_fwe.mk framework/source include/framework
Maxim Monastirsky
momonasmon at gmail.com
Thu Mar 10 22:54:24 UTC 2016
framework/Library_fwe.mk | 1
framework/source/fwe/classes/bmkmenu.cxx | 204 -----------------------
framework/source/fwe/xml/menuconfiguration.cxx | 13 -
framework/source/uielement/menubarmanager.cxx | 1
framework/source/uielement/newmenucontroller.cxx | 59 +++---
include/framework/bmkmenu.hxx | 66 -------
include/framework/menuconfiguration.hxx | 6
7 files changed, 34 insertions(+), 316 deletions(-)
New commits:
commit 42d6a165b053ebdccbd6979eb849b1abe305d2ba
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Fri Mar 11 00:45:56 2016 +0200
framework: Kill BmkMenu
Change-Id: I182e752f5602d946f27206a1bb744c5d2248bdf8
diff --git a/framework/Library_fwe.mk b/framework/Library_fwe.mk
index 848e52c..9b10e16 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 4b316a7..0000000
--- 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 1cec54b..fcda2ed 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 77f5be6..d740888 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 5e848bb..c48e66a 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++;
}
}
diff --git a/include/framework/bmkmenu.hxx b/include/framework/bmkmenu.hxx
deleted file mode 100644
index 54c4075..0000000
--- a/include/framework/bmkmenu.hxx
+++ /dev/null
@@ -1,66 +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 .
- */
-#ifndef INCLUDED_FRAMEWORK_BMKMENU_HXX
-#define INCLUDED_FRAMEWORK_BMKMENU_HXX
-
-#include <framework/addonmenu.hxx>
-
-#include <com/sun/star/frame/XFrame.hpp>
-#include <framework/fwedllapi.h>
-
-#include <vcl/menu.hxx>
-#include <vcl/image.hxx>
-
-class ImageList;
-
-#define BMKMENU_ITEMID_START 20000
-
-namespace framework
-{
-
-class BmkMenu_Impl;
-class FWE_DLLPUBLIC BmkMenu : public AddonMenu
-{
- public:
- enum BmkMenuType
- {
- BMK_NEWMENU,
- BMK_WIZARDMENU
- };
-
- BmkMenu( css::uno::Reference< css::frame::XFrame >& rFrame, BmkMenuType nType );
-
- virtual ~BmkMenu();
-
- void Initialize(); // Synchrones Laden der Eintraege
-
- protected:
- BmkMenu::BmkMenuType m_nType;
- sal_uInt16 CreateMenuId();
-
- private:
-
- BmkMenu_Impl* _pImp;
-};
-
-} // namespace framework
-
-#endif // INCLUDED_FRAMEWORK_BMKMENU_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/framework/menuconfiguration.hxx b/include/framework/menuconfiguration.hxx
index 2d00c07..3a618c2 100644
--- a/include/framework/menuconfiguration.hxx
+++ b/include/framework/menuconfiguration.hxx
@@ -36,9 +36,6 @@
#include <vcl/menu.hxx>
#include <vcl/toolbox.hxx>
-#define BOOKMARK_NEWMENU "private:menu_bookmark_new"
-#define BOOKMARK_WIZARDMENU "private:menu_bookmark_wizard"
-
// Prepare for inclusion by framework and sfx
// Please consider that there is a corresponding define also in sfxsids.hrc!! (SID_SFX_START)/(SID_ADDONS)
#define FWK_SID_SFX_START 5000
@@ -110,9 +107,6 @@ public:
css::uno::Reference< css::io::XInputStream >& rInputStream )
throw (css::lang::WrappedTargetException, css::uno::RuntimeException);
- PopupMenu* CreateBookmarkMenu(css::uno::Reference<css::frame::XFrame >& rFrame, const OUString& aURL)
- throw (css::lang::WrappedTargetException, css::uno::RuntimeException);
-
void StoreMenuBarConfigurationToXML(
css::uno::Reference< css::container::XIndexAccess >& rMenuBarConfiguration,
css::uno::Reference< css::io::XOutputStream >& rOutputStream,
More information about the Libreoffice-commits
mailing list