Kaydet (Commit) 52801217 authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

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/34407Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
üst 423beaf8
......@@ -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>
......
......@@ -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>
......@@ -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 \
))
......
......@@ -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 )
......
......@@ -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;
}
......
......@@ -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();
}
}
......
......@@ -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:";
......
<?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>
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment