officecfg/registry/data/org/openoffice/Office/UI/DbReportWindowState.xcu | 5 officecfg/registry/data/org/openoffice/Office/UI/ReportCommands.xcu | 10 reportdesign/UIConfig_dbreport.mk | 4 reportdesign/inc/RptResId.hrc | 5 reportdesign/source/ui/report/ReportController.cxx | 2 reportdesign/source/ui/report/ReportSection.cxx | 75 -- reportdesign/source/ui/report/report.src | 283 ---------- reportdesign/uiconfig/dbreport/popupmenu/report.xml | 68 ++ vcl/source/window/menu.cxx | 2 9 files changed, 110 insertions(+), 344 deletions(-)
New commits: commit 5280121732324eff5a30087a36a50c58524b8ef3 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Sat Feb 18 21:18:03 2017 +0200 Convert RID_MENU_REPORT to xml The change in PopupMenu::ImplExecute is needed because MenuBarManager dispatches commands synchronously, and a command can try to dispose the parent window of the MenuFloatingWindow (e.g. right clicking inside the report header, and choosing "Delete Header"), which will lead to Application::Abort in a debug build. So we must get rid of the MenuFloatingWindow before handling menu selection. Change-Id: I1657cd16a005207abc31f4b65595ab78ed235e37 Reviewed-on: https://gerrit.libreoffice.org/34407 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Maxim Monastirsky <momonas...@gmail.com> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DbReportWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DbReportWindowState.xcu index dc8c6b9..1260627 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/DbReportWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/DbReportWindowState.xcu @@ -19,6 +19,11 @@ <oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="DbReportWindowState" oor:package="org.openoffice.Office.UI"> <node oor:name="UIElements"> <node oor:name="States"> + <node oor:name="private:resource/popupmenu/report" oor:op="replace"> + <prop oor:name="UIName" oor:type="xs:string"> + <value xml:lang="en-US">Report</value> + </prop> + </node> <node oor:name="private:resource/toolbar/toolbar" oor:op="replace"> <prop oor:name="DockPos" oor:type="xs:string"> <value>0,1</value> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/ReportCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/ReportCommands.xcu index f3c0e37..a3b1378 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/ReportCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/ReportCommands.xcu @@ -308,6 +308,11 @@ <value>1</value> </prop> </node> + <node oor:name=".uno:DBBackgroundColor" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Background Color...</value> + </prop> + </node> </node> <node oor:name="Popups"> <node oor:name=".uno:ExportReportTo" oor:op="replace"> @@ -325,11 +330,6 @@ <value xml:lang="en-US">Object Resizing</value> </prop> </node> - <node oor:name=".uno:ArrangeMenu" oor:op="replace"> - <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">A~rrange</value> - </prop> - </node> </node> </node> </oor:component-data> diff --git a/reportdesign/UIConfig_dbreport.mk b/reportdesign/UIConfig_dbreport.mk index 5b8b4d4..8432711 100644 --- a/reportdesign/UIConfig_dbreport.mk +++ b/reportdesign/UIConfig_dbreport.mk @@ -13,6 +13,10 @@ $(eval $(call gb_UIConfig_add_menubarfiles,modules/dbreport,\ reportdesign/uiconfig/dbreport/menubar/menubar \ )) +$(eval $(call gb_UIConfig_add_popupmenufiles,modules/dbreport,\ + reportdesign/uiconfig/dbreport/popupmenu/report \ +)) + $(eval $(call gb_UIConfig_add_statusbarfiles,modules/dbreport,\ reportdesign/uiconfig/dbreport/statusbar/statusbar \ )) diff --git a/reportdesign/inc/RptResId.hrc b/reportdesign/inc/RptResId.hrc index b55a353..9ea0cf2 100644 --- a/reportdesign/inc/RptResId.hrc +++ b/reportdesign/inc/RptResId.hrc @@ -208,9 +208,8 @@ #define RID_STR_PARAADJUST (RID_STRING_START + 161) // menu ----------------------------------------------------------------------- -#define RID_MENU_REPORT ( RID_MENU_START + 0 ) -#define RID_GROUPSROWPOPUPMENU ( RID_MENU_START + 1 ) -#define RID_MENU_NAVIGATOR ( RID_MENU_START + 2 ) +#define RID_GROUPSROWPOPUPMENU ( RID_MENU_START + 0 ) +#define RID_MENU_NAVIGATOR ( RID_MENU_START + 1 ) // bitmaps #define RID_SVXBMP_SELECT_REPORT (RID_BITMAP_START + 0 ) #define RID_SVXBMP_FM_FIXEDTEXT (RID_BITMAP_START + 1 ) diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index ef0fd07..df020cb 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -1405,6 +1405,8 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue > uno::Reference<report::XSection> xSection; if (aArgs.getLength() == 1 ) aArgs[0].Value >>= xSection; + else if (_nId == SID_ATTR_CHAR_COLOR_BACKGROUND) + xSection.set(getDesignView()->getMarkedSection()->getReportSection().getSection()); openPageDialog(xSection); bForceBroadcast = true; } diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index 684384e..57eccdc 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -38,11 +38,13 @@ #include <svx/svditer.hxx> #include <svx/dbaexchange.hxx> -#include <vcl/commandinfoprovider.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> +#include <com/sun/star/frame/XPopupMenuController.hpp> +#include <comphelper/propertyvalue.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <toolkit/helper/convert.hxx> #include "RptDef.hxx" #include "SectionWindow.hxx" @@ -427,43 +429,6 @@ void OReportSection::SelectAll(const sal_uInt16 _nObjectType) } } } -void lcl_insertMenuItemImages( - PopupMenu& rContextMenu, - OReportController& rController, - const uno::Reference< report::XReportDefinition>& _xReportDefinition,uno::Reference<frame::XFrame>& _rFrame -) -{ - const sal_uInt16 nCount = rContextMenu.GetItemCount(); - for (sal_uInt16 i = 0; i < nCount; ++i) - { - if ( MenuItemType::SEPARATOR != rContextMenu.GetItemType(i)) - { - const sal_uInt16 nId = rContextMenu.GetItemId(i); - PopupMenu* pPopupMenu = rContextMenu.GetPopupMenu( nId ); - if ( pPopupMenu ) - { - lcl_insertMenuItemImages(*pPopupMenu,rController,_xReportDefinition,_rFrame); - } - else - { - const OUString sCommand = rContextMenu.GetItemCommand(nId); - rContextMenu.SetItemImage(nId, vcl::CommandInfoProvider::Instance().GetImageForCommand(sCommand, _rFrame)); - if ( nId == SID_PAGEHEADERFOOTER ) - { - OUString sText = ModuleRes((_xReportDefinition.is() && _xReportDefinition->getPageHeaderOn()) ? RID_STR_PAGEHEADERFOOTER_DELETE : RID_STR_PAGEHEADERFOOTER_INSERT); - rContextMenu.SetItemText(nId,sText); - } - else if ( nId == SID_REPORTHEADERFOOTER ) - { - OUString sText = ModuleRes((_xReportDefinition.is() && _xReportDefinition->getReportHeaderOn()) ? RID_STR_REPORTHEADERFOOTER_DELETE : RID_STR_REPORTHEADERFOOTER_INSERT); - rContextMenu.SetItemText(nId,sText); - } - } - rContextMenu.CheckItem(nId,rController.isCommandChecked(nId)); - rContextMenu.EnableItem(nId,rController.isCommandEnabled(nId)); - } - } -} void OReportSection::Command( const CommandEvent& _rCEvt ) { @@ -472,25 +437,29 @@ void OReportSection::Command( const CommandEvent& _rCEvt ) { OReportController& rController = m_pParent->getViewsWindow()->getView()->getReportView()->getController(); uno::Reference<frame::XFrame> xFrame = rController.getFrame(); - ScopedVclPtrInstance<PopupMenu> aContextMenu( ModuleRes( RID_MENU_REPORT ) ); - uno::Reference< report::XReportDefinition> xReportDefinition = getSection()->getReportDefinition(); + css::uno::Sequence<css::uno::Any> aArgs { + css::uno::makeAny(comphelper::makePropertyValue("Value", OUString("report"))), + css::uno::makeAny(comphelper::makePropertyValue("Frame", xFrame)), + css::uno::makeAny(comphelper::makePropertyValue("IsContextMenu", true)) + }; + + css::uno::Reference<css::uno::XComponentContext> xContext(rController.getORB()); + css::uno::Reference<css::frame::XPopupMenuController> xMenuController( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), css::uno::UNO_QUERY); + + if (!xMenuController.is()) + return; - lcl_insertMenuItemImages(*aContextMenu.get(),rController,xReportDefinition,xFrame); + rtl::Reference<VCLXPopupMenu> xPopupMenu(new VCLXPopupMenu); + xMenuController->setPopupMenu(xPopupMenu.get()); Point aPos = _rCEvt.GetMousePosPixel(); m_pView->EndAction(); - const sal_uInt16 nId = aContextMenu->Execute(this, aPos); - if ( nId ) - { - uno::Sequence< beans::PropertyValue> aArgs; - if ( nId == SID_ATTR_CHAR_COLOR_BACKGROUND ) - { - aArgs.realloc(1); - aArgs[0].Name = "Selection"; - aArgs[0].Value <<= m_xSection; - } - rController.executeChecked(nId,aArgs); - } + static_cast<PopupMenu*>(xPopupMenu->GetMenu())->Execute(this, aPos); + + css::uno::Reference<css::lang::XComponent> xComponent(xMenuController, css::uno::UNO_QUERY); + xComponent->dispose(); } } diff --git a/reportdesign/source/ui/report/report.src b/reportdesign/source/ui/report/report.src index 42279d6..84250e7 100644 --- a/reportdesign/source/ui/report/report.src +++ b/reportdesign/source/ui/report/report.src @@ -258,288 +258,7 @@ String RID_STR_GROUPFOOTER Text [ en-US ] = "GroupFooter"; Text [ x-comment ] = "Please try to avoid spaces in the name. It is used as a programmatic one."; }; -Menu RID_MENU_REPORT -{ - ItemList = - { - MenuItem - { - Identifier = SID_SORTINGANDGROUPING; - Command = ".uno:DbSortingAndGrouping"; - Text [ en-US ] = "Sorting and Grouping..."; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = SID_ATTR_CHAR_COLOR_BACKGROUND; - Command = ".uno:DBBackgroundColor"; - Text [ en-US ] = "Background Color..."; - }; - MenuItem - { - Identifier = SID_RULER; - Command = ".uno:ShowRuler"; - Checkable = TRUE; - Text [ en-US ] = "Ruler..."; - }; - MenuItem - { - Identifier = SID_GRID_VISIBLE; - Command = ".uno:GridVisible"; - Checkable = TRUE; - Text [ en-US ] = "Grid..."; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = SID_PAGEHEADERFOOTER; - Command = ".uno:PageHeaderFooter"; - Checkable = TRUE; - }; - MenuItem - { - Identifier = SID_REPORTHEADERFOOTER; - Command = ".uno:ReportHeaderFooter"; - Checkable = TRUE; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = SID_ARRANGEMENU ; - Command = ".uno:ArrangeMenu" ; - Text [ en-US ] = "~Arrange" ; - SubMenu = Menu - { - ItemList = - { - MenuItem - { - Identifier = SID_FRAME_TO_TOP ; - Command = ".uno:BringToFront" ; - Text [ en-US ] = "~Bring to Front" ; - }; - MenuItem - { - Identifier = SID_FRAME_UP ; - HelpId = ".uno:ObjectForwardOne"; - Text [ en-US ] = "Bring ~Forward" ; - }; - MenuItem - { - Identifier = SID_FRAME_DOWN ; - HelpId = ".uno:ObjectBackOne"; - Text [ en-US ] = "Send Back~ward" ; - }; - MenuItem - { - Identifier = SID_FRAME_TO_BOTTOM ; - Command = ".uno:SendToBack" ; - Text [ en-US ] = "~Send to Back" ; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = SID_OBJECT_HEAVEN ; - Command = ".uno:SetObjectToForeground" ; - Text [ en-US ] = "~To Foreground" ; - }; - MenuItem - { - Identifier = SID_OBJECT_HELL ; - Command = ".uno:SetObjectToBackground" ; - Text [ en-US ] = "T~o Background" ; - }; - }; - }; - }; - MenuItem - { - Identifier = SID_OBJECT_ALIGN ; - Command = ".uno:ObjectAlign" ; - Text [ en-US ] = "A~lignment" ; - SubMenu = Menu - { - ItemList = - { - MenuItem - { - Identifier = SID_OBJECT_ALIGN_LEFT ; - Command = ".uno:ObjectAlignLeft" ; - Text [ en-US ] = "~Left" ; - }; - MenuItem - { - Identifier = SID_OBJECT_ALIGN_CENTER ; - Command = ".uno:AlignCenter" ; - Text [ en-US ] = "~Centered" ; - }; - MenuItem - { - Identifier = SID_OBJECT_ALIGN_RIGHT ; - Command = ".uno:ObjectAlignRight" ; - Text [ en-US ] = "~Right" ; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = SID_OBJECT_ALIGN_UP ; - Command = ".uno:AlignUp" ; - Text [ en-US ] = "~Top" ; - }; - MenuItem - { - Identifier = SID_OBJECT_ALIGN_MIDDLE ; - Command = ".uno:AlignMiddle" ; - Text [ en-US ] = "C~enter" ; - }; - MenuItem - { - Identifier = SID_OBJECT_ALIGN_DOWN ; - Command = ".uno:AlignDown" ; - Text [ en-US ] = "~Bottom" ; - }; - }; - }; - }; - MenuItem - { - Separator = TRUE; - }; - - MenuItem - { - Identifier = SID_OBJECT_RESIZING ; - Command = ".uno:ObjectResize" ; - Text [ en-US ] = "~Object Resizing" ; - SubMenu = Menu - { - ItemList = - { - MenuItem - { - Identifier = SID_OBJECT_SMALLESTWIDTH ; - Command = ".uno:SmallestWidth" ; - Text [ en-US ] = "~Fit to smallest width" ; - }; - MenuItem - { - Identifier = SID_OBJECT_GREATESTWIDTH ; - Command = ".uno:GreatestWidth" ; - Text [ en-US ] = "~Fit to greatest width" ; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = SID_OBJECT_SMALLESTHEIGHT ; - Command = ".uno:SmallestHeight" ; - Text [ en-US ] = "~Fit to smallest height" ; - }; - MenuItem - { - Identifier = SID_OBJECT_GREATESTHEIGHT ; - Command = ".uno:GreatestHeight" ; - Text [ en-US ] = "~Fit to greatest height" ; - }; - }; - }; - }; - - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = SID_SECTION_SHRINK_MENU ; - Command = ".uno:SectionShrinkMenu" ; - Text [ en-US ] = "Section" ; - SubMenu = Menu - { - ItemList = - { - MenuItem - { - Identifier = SID_SECTION_SHRINK ; - Command = ".uno:SectionShrink" ; - Text [ en-US ] = "Shrink" ; - }; - MenuItem - { - Identifier = SID_SECTION_SHRINK_TOP ; - Command = ".uno:SectionShrinkTop" ; - Text [ en-US ] = "Shrink from top" ; - }; - MenuItem - { - Identifier = SID_SECTION_SHRINK_BOTTOM ; - Command = ".uno:SectionShrinkBottom" ; - Text [ en-US ] = "Shrink from bottom" ; - }; - }; - }; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = SID_DISTRIBUTION; - Command = ".uno:Distribution"; - Text [ en-US ] = "Distribution..." ; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = SID_SHOW_PROPERTYBROWSER; - Command = ".uno:FormProperties"; - Text [ en-US ] = "Properties..."; - }; - MenuItem - { - Separator = TRUE; - }; - MenuItem - { - Identifier = SID_CUT ; - Command = ".uno:Cut" ; - Text [ en-US ] = "Cu~t" ; - }; - MenuItem - { - Identifier = SID_COPY ; - Command = ".uno:Copy" ; - Text [ en-US ] = "~Copy" ; - }; - MenuItem - { - Identifier = SID_PASTE ; - Command = ".uno:Paste" ; - Text [ en-US ] = "~Paste" ; - }; - }; -}; + String RID_STR_FIELDSELECTION { Text [ en-US ] = "Add field:"; diff --git a/reportdesign/uiconfig/dbreport/popupmenu/report.xml b/reportdesign/uiconfig/dbreport/popupmenu/report.xml new file mode 100644 index 0000000..5605aa9 --- /dev/null +++ b/reportdesign/uiconfig/dbreport/popupmenu/report.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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/. + * +--> +<menu:menupopup xmlns:menu="http://openoffice.org/2001/menu"> + <menu:menuitem menu:id=".uno:Cut"/> + <menu:menuitem menu:id=".uno:Copy"/> + <menu:menuitem menu:id=".uno:Paste"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:DbSortingAndGrouping"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:DBBackgroundColor"/> + <menu:menuitem menu:id=".uno:ShowRuler"/> + <menu:menuitem menu:id=".uno:GridVisible"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:PageHeaderFooter"/> + <menu:menuitem menu:id=".uno:ReportHeaderFooter"/> + <menu:menuseparator/> + <menu:menu menu:id=".uno:ArrangeMenu"> + <menu:menupopup> + <menu:menuitem menu:id=".uno:BringToFront"/> + <menu:menuitem menu:id=".uno:ObjectBackOne"/> + <menu:menuitem menu:id=".uno:ObjectForwardOne"/> + <menu:menuitem menu:id=".uno:SendToBack"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:SetObjectToForeground"/> + <menu:menuitem menu:id=".uno:SetObjectToBackground"/> + </menu:menupopup> + </menu:menu> + <menu:menu menu:id=".uno:ObjectAlign"> + <menu:menupopup> + <menu:menuitem menu:id=".uno:ObjectAlignLeft"/> + <menu:menuitem menu:id=".uno:AlignCenter"/> + <menu:menuitem menu:id=".uno:ObjectAlignRight"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:AlignUp"/> + <menu:menuitem menu:id=".uno:AlignMiddle"/> + <menu:menuitem menu:id=".uno:AlignDown"/> + </menu:menupopup> + </menu:menu> + <menu:menuseparator/> + <menu:menu menu:id=".uno:ObjectResize"> + <menu:menupopup> + <menu:menuitem menu:id=".uno:SmallestWidth"/> + <menu:menuitem menu:id=".uno:GreatestWidth"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:SmallestHeight"/> + <menu:menuitem menu:id=".uno:GreatestHeight"/> + </menu:menupopup> + </menu:menu> + <menu:menuseparator/> + <menu:menu menu:id=".uno:SectionShrinkMenu"> + <menu:menupopup> + <menu:menuitem menu:id=".uno:SectionShrink"/> + <menu:menuitem menu:id=".uno:SectionShrinkTop"/> + <menu:menuitem menu:id=".uno:SectionShrinkBottom"/> + </menu:menupopup> + </menu:menu> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:Distribution"/> + <menu:menuseparator/> + <menu:menuitem menu:id=".uno:ControlProperties"/> +</menu:menupopup> diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 5a1a2f7..52b8688 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -3017,11 +3017,11 @@ sal_uInt16 PopupMenu::ImplExecute( const VclPtr<vcl::Window>& pW, const Rectangl SalMenu* pMenu = ImplGetSalMenu(); if( pMenu && bRealExecute && pMenu->ShowNativePopupMenu( pWin, aRect, nPopupModeFlags | FloatWinPopupFlags::GrabFocus ) ) { - ImplFlushPendingSelect(); pWin->StopExecute(); pWin->doShutdown(); pWindow->doLazyDelete(); pWindow = nullptr; + ImplFlushPendingSelect(); return nSelectedId; } else _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits