diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-04-13 11:48:20 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-13 12:02:02 +0100 |
commit | 171477fb08e4b27b9659dc93bbd18480ab4930a7 (patch) | |
tree | 9289e2f5793d71c5508b545884d6961e6bd81d75 /sd/source | |
parent | 26dcda4cc1f04e1c11e82f9136a0678e4c72bed8 (diff) |
convert master page menus to .ui
Change-Id: I7ab0ad0f3216b69966f5ff345b052762993eb666
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/app/popup.src | 111 | ||||
-rw-r--r-- | sd/source/ui/inc/res_bmp.hrc | 5 | ||||
-rw-r--r-- | sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx | 22 | ||||
-rw-r--r-- | sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx | 4 | ||||
-rw-r--r-- | sd/source/ui/sidebar/MasterPagesSelector.cxx | 119 | ||||
-rw-r--r-- | sd/source/ui/sidebar/MasterPagesSelector.hxx | 8 | ||||
-rw-r--r-- | sd/source/ui/sidebar/RecentMasterPagesSelector.cxx | 5 |
7 files changed, 74 insertions, 200 deletions
diff --git a/sd/source/ui/app/popup.src b/sd/source/ui/app/popup.src deleted file mode 100644 index aad53501ce1c..000000000000 --- a/sd/source/ui/app/popup.src +++ /dev/null @@ -1,111 +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 <svx/dialogs.hrc> - #include "app.hrc" - #include "res_bmp.hrc" - #include "helpids.h" - - #define SEPARATOR MenuItem { Separator = TRUE; }; - -Menu RID_TASKPANE_MASTERPAGESSELECTOR_POPUP -{ - ItemList = - { - MenuItem - { - Identifier = SID_TP_APPLY_TO_ALL_SLIDES; - HelpId = CMD_SID_TP_APPLY_TO_ALL_SLIDES; - Text [ en-US ] = "~Apply to All Slides"; - }; - MenuItem - { - Identifier = SID_TP_APPLY_TO_SELECTED_SLIDES; - HelpId = CMD_SID_TP_APPLY_TO_SELECTED_SLIDES; - Text [ en-US ] = "Apply to ~Selected Slides"; - }; - - SEPARATOR - - MenuItem - { - Identifier = SID_TP_SHOW_LARGE_PREVIEW; - HelpId = CMD_SID_TP_SHOW_LARGE_PREVIEW; - Text[ en-US ] = "Show ~Large Preview"; - }; - MenuItem - { - Identifier = SID_TP_SHOW_SMALL_PREVIEW; - HelpId = CMD_SID_TP_SHOW_SMALL_PREVIEW; - Text[ en-US ] = "Show S~mall Preview"; - }; - }; -}; - -Menu RID_TASKPANE_CURRENT_MASTERPAGESSELECTOR_POPUP -{ - ItemList = - { - MenuItem - { - Identifier = SID_TP_APPLY_TO_ALL_SLIDES; - HelpId = CMD_SID_TP_APPLY_TO_ALL_SLIDES; - Text [ en-US ] = "~Apply to All Slides"; - }; - MenuItem - { - Identifier = SID_TP_APPLY_TO_SELECTED_SLIDES; - HelpId = CMD_SID_TP_APPLY_TO_SELECTED_SLIDES; - Text [ en-US ] = "Apply to ~Selected Slides"; - }; - - SEPARATOR - - MenuItem - { - Identifier = SID_TP_EDIT_MASTER; - HelpId = CMD_SID_TP_EDIT_MASTER; - Text[ en-US ] = "~Edit Master..."; - }; - - MenuItem - { - Identifier = SID_DELETE_MASTER_PAGE; - HelpId = CMD_SID_DELETE_MASTER_PAGE; - Text [ en-US ] = "D~elete Master"; - }; - - SEPARATOR - - MenuItem - { - Identifier = SID_TP_SHOW_LARGE_PREVIEW; - HelpId = CMD_SID_TP_SHOW_LARGE_PREVIEW; - Text[ en-US ] = "Show ~Large Preview"; - }; - MenuItem - { - Identifier = SID_TP_SHOW_SMALL_PREVIEW; - HelpId = CMD_SID_TP_SHOW_SMALL_PREVIEW; - Text[ en-US ] = "Show S~mall Preview"; - }; - }; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/inc/res_bmp.hrc b/sd/source/ui/inc/res_bmp.hrc index a6c240efa51a..39706b03e44a 100644 --- a/sd/source/ui/inc/res_bmp.hrc +++ b/sd/source/ui/inc/res_bmp.hrc @@ -196,11 +196,6 @@ #define BMP_PRESENTERSCREEN_BUTTON_RESTART_TIMER_MOUSE_OVER (RID_SD_START+594) #define BMP_PRESENTERSCREEN_BUTTON_RESTART_TIMER_NORMAL (RID_SD_START+595) -// ResourceIDs for Popup-Menus do not need a dummy string!!! - -#define RID_TASKPANE_MASTERPAGESSELECTOR_POPUP RID_APP_START+67 -#define RID_TASKPANE_CURRENT_MASTERPAGESSELECTOR_POPUP RID_APP_START+93 - #define RID_GRAPHICSTYLEFAMILY RID_APP_START+395 #define RID_PRESENTATIONSTYLEFAMILY RID_APP_START+396 #define BMP_STYLES_FAMILY_GRAPHICS RID_APP_START+397 diff --git a/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx b/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx index 9db8fcbf204e..32cc5bc321d4 100644 --- a/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx +++ b/sd/source/ui/sidebar/CurrentMasterPagesSelector.cxx @@ -152,9 +152,9 @@ void CurrentMasterPagesSelector::Fill (ItemList& rItemList) } } -ResId CurrentMasterPagesSelector::GetContextMenuResId() const +OUString CurrentMasterPagesSelector::GetContextMenuUIFile() const { - return SdResId(RID_TASKPANE_CURRENT_MASTERPAGESSELECTOR_POPUP); + return "modules/simpress/ui/currentmastermenu.ui"; } void CurrentMasterPagesSelector::UpdateSelection() @@ -202,9 +202,9 @@ void CurrentMasterPagesSelector::UpdateSelection() } } -void CurrentMasterPagesSelector::ExecuteCommand (const sal_Int32 nCommandId) +void CurrentMasterPagesSelector::ExecuteCommand(const OString &rIdent) { - if (nCommandId == SID_DELETE_MASTER_PAGE) + if (rIdent == "delete") { // Check once again that the master page can safely be deleted, // i.e. is not used. @@ -219,16 +219,17 @@ void CurrentMasterPagesSelector::ExecuteCommand (const sal_Int32 nCommandId) } } else - MasterPagesSelector::ExecuteCommand(nCommandId); + MasterPagesSelector::ExecuteCommand(rIdent); } void CurrentMasterPagesSelector::ProcessPopupMenu (Menu& rMenu) { - // Disable the SID_DELTE_MASTER slot when there is only one master page. + // Disable the delete entry when there is only one master page. if (mrDocument.GetMasterPageUserCount(GetSelectedMasterPage()) > 0) { - if (rMenu.GetItemPos(SID_DELETE_MASTER_PAGE) != MENU_ITEM_NOTFOUND) - rMenu.EnableItem(SID_DELETE_MASTER_PAGE, false); + sal_uInt16 nItemid = rMenu.GetItemId("delete"); + if (rMenu.GetItemPos(nItemid) != MENU_ITEM_NOTFOUND) + rMenu.EnableItem(nItemid, false); } std::shared_ptr<DrawViewShell> pDrawViewShell ( @@ -236,8 +237,9 @@ void CurrentMasterPagesSelector::ProcessPopupMenu (Menu& rMenu) if (pDrawViewShell && pDrawViewShell->GetEditMode() == EditMode::MasterPage) { - if (rMenu.GetItemPos(SID_TP_EDIT_MASTER) != MENU_ITEM_NOTFOUND) - rMenu.EnableItem(SID_TP_EDIT_MASTER, false); + sal_uInt16 nItemid = rMenu.GetItemId("edit"); + if (rMenu.GetItemPos(nItemid) != MENU_ITEM_NOTFOUND) + rMenu.EnableItem(nItemid, false); } MasterPagesSelector::ProcessPopupMenu(rMenu); diff --git a/sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx b/sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx index 8f3daac12267..01f1d9b55e92 100644 --- a/sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx +++ b/sd/source/ui/sidebar/CurrentMasterPagesSelector.hxx @@ -54,10 +54,10 @@ public: using MasterPagesSelector::Fill; protected: - virtual ResId GetContextMenuResId() const override; + virtual OUString GetContextMenuUIFile() const override; virtual void ProcessPopupMenu (Menu& rMenu) override; - virtual void ExecuteCommand (const sal_Int32 nCommandId) override; + virtual void ExecuteCommand(const OString &rIdent) override; private: CurrentMasterPagesSelector ( diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx b/sd/source/ui/sidebar/MasterPagesSelector.cxx index fc9c06ba6da3..e531a2c592e3 100644 --- a/sd/source/ui/sidebar/MasterPagesSelector.cxx +++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx @@ -75,7 +75,7 @@ MasterPagesSelector::MasterPagesSelector ( mpContainer(rpContainer), mrDocument(rDocument), mrBase(rBase), - mnDefaultClickAction(SID_TP_APPLY_TO_SELECTED_SLIDES), + msDefaultClickAction("applyselect"), maCurrentItemList(), maTokenToValueSetIndex(), maLockedMasterPages(), @@ -164,9 +164,9 @@ void MasterPagesSelector::Fill() UpdateItemList(std::move(pItemList)); } -ResId MasterPagesSelector::GetContextMenuResId() const +OUString MasterPagesSelector::GetContextMenuUIFile() const { - return SdResId(RID_TASKPANE_MASTERPAGESSELECTOR_POPUP); + return "modules/simpress/ui/mastermenu.ui"; } IMPL_LINK_NOARG(MasterPagesSelector, ClickHandler, ValueSet*, void) @@ -174,7 +174,7 @@ IMPL_LINK_NOARG(MasterPagesSelector, ClickHandler, ValueSet*, void) // We use the framework to assign the clicked-on master page because we // so use the same mechanism as the context menu does (where we do not // have the option to call the assignment method directly.) - ExecuteCommand(mnDefaultClickAction); + ExecuteCommand(msDefaultClickAction); } IMPL_LINK(MasterPagesSelector, RightClickHandler, const MouseEvent&, rEvent, void) @@ -221,7 +221,8 @@ void MasterPagesSelector::Command (const CommandEvent& rEvent) } // Setup the menu. - ScopedVclPtrInstance<PopupMenu> pMenu(GetContextMenuResId()); + VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), GetContextMenuUIFile(), ""); + VclPtr<PopupMenu> pMenu(aBuilder.get_menu("menu")); FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); if (pMenuWindow != nullptr) pMenuWindow->SetPopupModeFlags( @@ -243,9 +244,9 @@ void MasterPagesSelector::ProcessPopupMenu (Menu& rMenu) { // Disable some entries. if (mpContainer->GetPreviewSize() == MasterPageContainer::SMALL) - rMenu.EnableItem(SID_TP_SHOW_SMALL_PREVIEW, false); + rMenu.EnableItem(rMenu.GetItemId("small"), false); else - rMenu.EnableItem(SID_TP_SHOW_LARGE_PREVIEW, false); + rMenu.EnableItem(rMenu.GetItemId("large"), false); } IMPL_LINK(MasterPagesSelector, OnMenuItemSelected, Menu*, pMenu, bool) @@ -257,74 +258,60 @@ IMPL_LINK(MasterPagesSelector, OnMenuItemSelected, Menu*, pMenu, bool) } pMenu->Deactivate(); - ExecuteCommand(pMenu->GetCurItemId()); + ExecuteCommand(pMenu->GetCurItemIdent()); return false; } -void MasterPagesSelector::ExecuteCommand (const sal_Int32 nCommandId) +void MasterPagesSelector::ExecuteCommand(const OString &rIdent) { - switch (nCommandId) + if (rIdent == "applyall") { - case SID_TP_APPLY_TO_ALL_SLIDES: - mrBase.SetBusyState (true); - AssignMasterPageToAllSlides (GetSelectedMasterPage()); - mrBase.SetBusyState (false); - break; - - case SID_TP_APPLY_TO_SELECTED_SLIDES: - mrBase.SetBusyState (true); - AssignMasterPageToSelectedSlides (GetSelectedMasterPage()); - mrBase.SetBusyState (false); - break; - - case SID_TP_USE_FOR_NEW_PRESENTATIONS: - SAL_WARN ( "sd", - "Using slides as default for new presentations" - " is not yet implemented"); - break; - - case SID_TP_SHOW_SMALL_PREVIEW: - case SID_TP_SHOW_LARGE_PREVIEW: - { - mrBase.SetBusyState (true); - mpContainer->SetPreviewSize( - nCommandId==SID_TP_SHOW_SMALL_PREVIEW - ? MasterPageContainer::SMALL - : MasterPageContainer::LARGE); - mrBase.SetBusyState (false); - if (mxSidebar.is()) - mxSidebar->requestLayout(); - break; - } - - case SID_TP_EDIT_MASTER: + mrBase.SetBusyState (true); + AssignMasterPageToAllSlides (GetSelectedMasterPage()); + mrBase.SetBusyState (false); + } + else if (rIdent == "applyselect") + { + mrBase.SetBusyState (true); + AssignMasterPageToSelectedSlides (GetSelectedMasterPage()); + mrBase.SetBusyState (false); + } + else if (rIdent == "large") + { + mrBase.SetBusyState (true); + mpContainer->SetPreviewSize(MasterPageContainer::LARGE); + mrBase.SetBusyState (false); + if (mxSidebar.is()) + mxSidebar->requestLayout(); + } + else if (rIdent == "small") + { + mrBase.SetBusyState (true); + mpContainer->SetPreviewSize(MasterPageContainer::SMALL); + mrBase.SetBusyState (false); + if (mxSidebar.is()) + mxSidebar->requestLayout(); + } + else if (rIdent == "edit") + { + using namespace ::com::sun::star; + uno::Reference<drawing::XDrawPage> xSelectedMaster; + SdPage* pMasterPage = GetSelectedMasterPage(); + assert(pMasterPage); //rhbz#902884 + if (pMasterPage) + xSelectedMaster.set(pMasterPage->getUnoPage(), uno::UNO_QUERY); + SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); + if (pViewFrame != nullptr && xSelectedMaster.is()) { - using namespace ::com::sun::star; - uno::Reference<drawing::XDrawPage> xSelectedMaster; - SdPage* pMasterPage = GetSelectedMasterPage(); - assert(pMasterPage); //rhbz#902884 - if (pMasterPage) - xSelectedMaster.set(pMasterPage->getUnoPage(), uno::UNO_QUERY); - SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); - if (pViewFrame != nullptr && xSelectedMaster.is()) + SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); + if (pDispatcher != nullptr) { - SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); - if (pDispatcher != nullptr) - { - sal_uInt16 nIndex = PreviewValueSet::GetSelectItemId(); - pDispatcher->Execute(SID_MASTERPAGE, SfxCallMode::SYNCHRON); - PreviewValueSet::SelectItem (nIndex); - mrBase.GetDrawController().setCurrentPage(xSelectedMaster); - } + sal_uInt16 nIndex = PreviewValueSet::GetSelectItemId(); + pDispatcher->Execute(SID_MASTERPAGE, SfxCallMode::SYNCHRON); + PreviewValueSet::SelectItem (nIndex); + mrBase.GetDrawController().setCurrentPage(xSelectedMaster); } - break; } - - case SID_CUT: - case SID_COPY: - case SID_PASTE: - // Cut, copy, and paste are not supported and thus are ignored. - break; } } diff --git a/sd/source/ui/sidebar/MasterPagesSelector.hxx b/sd/source/ui/sidebar/MasterPagesSelector.hxx index d7271c63c72a..e5ce79854654 100644 --- a/sd/source/ui/sidebar/MasterPagesSelector.hxx +++ b/sd/source/ui/sidebar/MasterPagesSelector.hxx @@ -112,10 +112,10 @@ protected: SdDrawDocument& mrDocument; ViewShellBase& mrBase; - /** Slot that is executed as default action when the left mouse button is + /** menu entry that is executed as default action when the left mouse button is clicked over a master page. */ - sal_uInt16 mnDefaultClickAction; + OString msDefaultClickAction; SdPage* GetSelectedMasterPage(); @@ -170,12 +170,12 @@ protected: menu. If they do then they probably have to provide their own Execute() and GetState() methods as well. */ - virtual ResId GetContextMenuResId() const; + virtual OUString GetContextMenuUIFile() const; virtual void Command (const CommandEvent& rEvent) override; virtual void ProcessPopupMenu (Menu& rMenu); - virtual void ExecuteCommand (const sal_Int32 nCommandId); + virtual void ExecuteCommand(const OString& rIdent); private: css::uno::Reference<css::ui::XSidebar> mxSidebar; diff --git a/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx b/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx index 7ff9accbfff0..6e32ec496413 100644 --- a/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx +++ b/sd/source/ui/sidebar/RecentMasterPagesSelector.cxx @@ -145,8 +145,9 @@ void RecentMasterPagesSelector::AssignMasterPageToPageList ( void RecentMasterPagesSelector::ProcessPopupMenu (Menu& rMenu) { - if (rMenu.GetItemPos(SID_TP_EDIT_MASTER) != MENU_ITEM_NOTFOUND) - rMenu.EnableItem(SID_TP_EDIT_MASTER, false); + sal_uInt16 nItemid = rMenu.GetItemId("edit"); + if (rMenu.GetItemPos(nItemid) != MENU_ITEM_NOTFOUND) + rMenu.EnableItem(nItemid, false); } } } // end of namespace sd::sidebar |