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

tdf#93837 chart2: Convert shape context menus to xml

Change-Id: Ie0589c576b26dd74b9bc16d78a37a01c9bb2985e
üst 56cbb379
...@@ -35,8 +35,6 @@ $(eval $(call gb_SrsTarget_add_files,chart2/res,\ ...@@ -35,8 +35,6 @@ $(eval $(call gb_SrsTarget_add_files,chart2/res,\
$(eval $(call gb_SrsTarget_add_nonlocalizable_files,chart2/res,\ $(eval $(call gb_SrsTarget_add_nonlocalizable_files,chart2/res,\
chart2/source/controller/dialogs/Bitmaps.src \ chart2/source/controller/dialogs/Bitmaps.src \
chart2/source/controller/menus/ShapeContextMenu.src \
chart2/source/controller/menus/ShapeEditContextMenu.src \
)) ))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -13,6 +13,11 @@ $(eval $(call gb_UIConfig_add_menubarfiles,modules/schart,\ ...@@ -13,6 +13,11 @@ $(eval $(call gb_UIConfig_add_menubarfiles,modules/schart,\
chart2/uiconfig/menubar/menubar \ chart2/uiconfig/menubar/menubar \
)) ))
$(eval $(call gb_UIConfig_add_popupmenufiles,modules/schart,\
chart2/uiconfig/popupmenu/draw \
chart2/uiconfig/popupmenu/drawtext \
))
$(eval $(call gb_UIConfig_add_statusbarfiles,modules/schart,\ $(eval $(call gb_UIConfig_add_statusbarfiles,modules/schart,\
chart2/uiconfig/statusbar/statusbar \ chart2/uiconfig/statusbar/statusbar \
)) ))
......
/* -*- 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 CHART_MENURESIDS_HRC
#define CHART_MENURESIDS_HRC
#include <svl/solar.hrc>
// context menus
#define RID_CONTEXTMENU_SHAPE (RID_APP_START + 1)
#define RID_CONTEXTMENU_SHAPEEDIT (RID_APP_START + 2)
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -44,18 +44,20 @@ ...@@ -44,18 +44,20 @@
#include "AxisHelper.hxx" #include "AxisHelper.hxx"
#include "LegendHelper.hxx" #include "LegendHelper.hxx"
#include "servicenames_charttypes.hxx" #include "servicenames_charttypes.hxx"
#include "MenuResIds.hrc"
#include "DrawCommandDispatch.hxx" #include "DrawCommandDispatch.hxx"
#include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp> #include <com/sun/star/chart2/RelativeSize.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/awt/PopupMenuDirection.hpp>
#include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/frame/DispatchHelper.hpp>
#include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp>
#include <com/sun/star/frame/XPopupMenuController.hpp>
#include <com/sun/star/util/XUpdatable.hpp> #include <com/sun/star/util/XUpdatable.hpp>
#include <comphelper/InlineContainer.hxx> #include <comphelper/InlineContainer.hxx>
#include <comphelper/propertysequence.hxx> #include <comphelper/propertysequence.hxx>
#include <comphelper/propertyvalue.hxx>
#include <svtools/contextmenuhelper.hxx> #include <svtools/contextmenuhelper.hxx>
#include <toolkit/awt/vclxmenu.hxx> #include <toolkit/awt/vclxmenu.hxx>
...@@ -950,27 +952,45 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) ...@@ -950,27 +952,45 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() ) if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() )
impl_notifySelectionChangeListeners(); impl_notifySelectionChangeListeners();
css::uno::Reference< css::awt::XPopupMenu > xPopupMenu( m_xCC->getServiceManager()->createInstanceWithContext(
"com.sun.star.awt.PopupMenu", m_xCC ), css::uno::UNO_QUERY );
Point aPos( rCEvt.GetMousePosPixel() );
if( !rCEvt.IsMouseEvent() )
{
SolarMutexGuard aGuard;
if(m_pChartWindow)
aPos = m_pChartWindow->GetPointerState().maPos;
}
if ( isShapeContext() ) if ( isShapeContext() )
{ {
// #i12587# support for shapes in chart // #i12587# support for shapes in chart
PopupMenu aContextMenu( SchResId( m_pDrawViewWrapper->IsTextEdit() ? OUString aMenuName = m_pDrawViewWrapper->IsTextEdit() ? OUString( "drawtext" ) : OUString( "draw" );
RID_CONTEXTMENU_SHAPEEDIT : RID_CONTEXTMENU_SHAPE ) ); css::uno::Sequence< css::uno::Any > aArgs( 3 );
::svt::ContextMenuHelper aContextMenuHelper( m_xFrame ); aArgs[0] <<= comphelper::makePropertyValue( "Value", aMenuName );
Point aPos( rCEvt.GetMousePosPixel() ); aArgs[1] <<= comphelper::makePropertyValue( "Frame", m_xFrame );
if( !rCEvt.IsMouseEvent() ) aArgs[2] <<= comphelper::makePropertyValue( "IsContextMenu", true );
{
SolarMutexGuard aGuard; css::uno::Reference< css::frame::XPopupMenuController > xPopupController(
if(m_pChartWindow) m_xCC->getServiceManager()->createInstanceWithArgumentsAndContext(
aPos = m_pChartWindow->GetPointerState().maPos; "com.sun.star.comp.framework.ResourceMenuController", aArgs, m_xCC ), css::uno::UNO_QUERY );
}
aContextMenuHelper.completeAndExecute( aPos, aContextMenu ); if ( !xPopupController.is() || !xPopupMenu.is() )
return;
xPopupController->setPopupMenu( xPopupMenu );
xPopupMenu->execute( css::uno::Reference< css::awt::XWindowPeer >( m_xFrame->getContainerWindow(), css::uno::UNO_QUERY ),
css::awt::Rectangle( aPos.X(), aPos.Y(), 0, 0 ),
css::awt::PopupMenuDirection::EXECUTE_DEFAULT );
css::uno::Reference< css::lang::XComponent > xComponent( xPopupController, css::uno::UNO_QUERY );
if ( xComponent.is() )
xComponent->dispose();
} }
else else
{ {
// todo: the context menu should be specified by an xml file in uiconfig // todo: the context menu should be specified by an xml file in uiconfig
uno::Reference< awt::XPopupMenu > xPopupMenu(
m_xCC->getServiceManager()->createInstanceWithContext(
"com.sun.star.awt.PopupMenu", m_xCC ), uno::UNO_QUERY );
if( xPopupMenu.is()) if( xPopupMenu.is())
{ {
sal_Int16 nUniqueId = 1; sal_Int16 nUniqueId = 1;
...@@ -1218,13 +1238,6 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) ...@@ -1218,13 +1238,6 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Paste" ); lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Paste" );
::svt::ContextMenuHelper aContextMenuHelper( m_xFrame ); ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame );
Point aPos( rCEvt.GetMousePosPixel() );
if( !rCEvt.IsMouseEvent() )
{
SolarMutexGuard aGuard;
if(m_pChartWindow)
aPos = m_pChartWindow->GetPointerState().maPos;
}
aContextMenuHelper.completeAndExecute( aPos, xPopupMenu ); aContextMenuHelper.completeAndExecute( aPos, xPopupMenu );
} }
} }
......
/* -*- 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 "MenuResIds.hrc"
#include "ShapeController.hrc"
Menu RID_CONTEXTMENU_SHAPE
{
ItemList =
{
MenuItem
{
Identifier = COMMAND_ID_FORMAT_LINE;
Command = ".uno:FormatLine";
};
MenuItem
{
Identifier = COMMAND_ID_FORMAT_AREA;
Command = ".uno:FormatArea";
};
MenuItem
{
Identifier = COMMAND_ID_TEXT_ATTRIBUTES;
Command = ".uno:TextAttributes";
};
MenuItem
{
Identifier = COMMAND_ID_TRANSFORM_DIALOG;
Command = ".uno:TransformDialog";
};
MenuItem
{
Separator = TRUE;
};
MenuItem
{
Identifier = COMMAND_ID_OBJECT_TITLE_DESCRIPTION;
Command = ".uno:ObjectTitleDescription";
};
MenuItem
{
Identifier = COMMAND_ID_RENAME_OBJECT;
Command = ".uno:RenameObject";
};
MenuItem
{
Separator = TRUE;
};
MenuItem
{
Identifier = COMMAND_ID_ARRANGE_ROW;
Command = ".uno:ArrangeRow";
SubMenu = Menu
{
ItemList =
{
MenuItem
{
Identifier = COMMAND_ID_BRING_TO_FRONT;
Command = ".uno:BringToFront";
};
MenuItem
{
Identifier = COMMAND_ID_FORWARD;
Command = ".uno:Forward";
};
MenuItem
{
Identifier = COMMAND_ID_BACKWARD;
Command = ".uno:Backward";
};
MenuItem
{
Identifier = COMMAND_ID_SEND_TO_BACK;
Command = ".uno:SendToBack";
};
};
};
};
MenuItem
{
Separator = TRUE;
};
MenuItem
{
Identifier = COMMAND_ID_CUT;
Command = ".uno:Cut";
};
MenuItem
{
Identifier = COMMAND_ID_COPY;
Command = ".uno:Copy";
};
MenuItem
{
Identifier = COMMAND_ID_PASTE;
Command = ".uno:Paste";
};
};
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 "MenuResIds.hrc"
#include "ShapeController.hrc"
Menu RID_CONTEXTMENU_SHAPEEDIT
{
ItemList =
{
MenuItem
{
Identifier = COMMAND_ID_FONT_DIALOG;
Command = ".uno:FontDialog";
};
MenuItem
{
Identifier = COMMAND_ID_PARAGRAPH_DIALOG;
Command = ".uno:ParagraphDialog";
};
MenuItem
{
Separator = TRUE;
};
MenuItem
{
Identifier = COMMAND_ID_CUT;
Command = ".uno:Cut";
};
MenuItem
{
Identifier = COMMAND_ID_COPY;
Command = ".uno:Copy";
};
MenuItem
{
Identifier = COMMAND_ID_PASTE;
Command = ".uno:Paste";
};
};
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<?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:FormatLine"/>
<menu:menuitem menu:id=".uno:FormatArea"/>
<menu:menuitem menu:id=".uno:TextAttributes"/>
<menu:menuitem menu:id=".uno:TransformDialog"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:ObjectTitleDescription"/>
<menu:menuitem menu:id=".uno:RenameObject"/>
<menu:menuseparator/>
<menu:menu menu:id=".uno:ArrangeRow">
<menu:menupopup>
<menu:menuitem menu:id=".uno:BringToFront"/>
<menu:menuitem menu:id=".uno:Forward"/>
<menu:menuitem menu:id=".uno:Backward"/>
<menu:menuitem menu:id=".uno:SendToBack"/>
</menu:menupopup>
</menu:menu>
</menu:menupopup>
<?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:FontDialog"/>
<menu:menuitem menu:id=".uno:ParagraphDialog"/>
</menu:menupopup>
...@@ -55,9 +55,8 @@ class SVT_DLLPUBLIC ContextMenuHelper ...@@ -55,9 +55,8 @@ class SVT_DLLPUBLIC ContextMenuHelper
ContextMenuHelper( const css::uno::Reference< css::frame::XFrame >& xFrame ); ContextMenuHelper( const css::uno::Reference< css::frame::XFrame >& xFrame );
~ContextMenuHelper(); ~ContextMenuHelper();
// methods to complete a popup menu (set images, labels, enable/disable states) // method to complete a popup menu (set images, labels, enable/disable states)
// ATTENTION: The item ID's must be unique for the whole popup (inclusive the sub menus!) // ATTENTION: The item ID's must be unique for the whole popup (inclusive the sub menus!)
void completeAndExecute( const Point& aPos, PopupMenu& aPopupMenu );
void completeAndExecute( const Point& aPos, const css::uno::Reference< css::awt::XPopupMenu >& xPopupMenu ); void completeAndExecute( const Point& aPos, const css::uno::Reference< css::awt::XPopupMenu >& xPopupMenu );
private: private:
......
...@@ -20,6 +20,16 @@ ...@@ -20,6 +20,16 @@
<oor:component-data xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="ChartWindowState" oor:package="org.openoffice.Office.UI"> <oor:component-data xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="ChartWindowState" oor:package="org.openoffice.Office.UI">
<node oor:name="UIElements"> <node oor:name="UIElements">
<node oor:name="States"> <node oor:name="States">
<node oor:name="private:resource/popupmenu/draw" oor:op="replace">
<prop oor:name="UIName" oor:type="xs:string">
<value xml:lang="en-US">Shape</value>
</prop>
</node>
<node oor:name="private:resource/popupmenu/drawtext" oor:op="replace">
<prop oor:name="UIName" oor:type="xs:string">
<value xml:lang="en-US">Shape Text</value>
</prop>
</node>
<node oor:name="private:resource/toolbar/standardbar" oor:op="replace"> <node oor:name="private:resource/toolbar/standardbar" oor:op="replace">
<prop oor:name="Docked" oor:type="xs:boolean"> <prop oor:name="Docked" oor:type="xs:boolean">
<value>true</value> <value>true</value>
......
...@@ -263,19 +263,6 @@ ContextMenuHelper::~ContextMenuHelper() ...@@ -263,19 +263,6 @@ ContextMenuHelper::~ContextMenuHelper()
{ {
} }
void
ContextMenuHelper::completeAndExecute(
const Point& aPos,
PopupMenu& rPopupMenu )
{
SolarMutexGuard aSolarGuard;
associateUIConfigurationManagers();
completeMenuProperties( &rPopupMenu );
executePopupMenu( aPos, &rPopupMenu );
resetAssociations();
}
void void
ContextMenuHelper::completeAndExecute( ContextMenuHelper::completeAndExecute(
const Point& aPos, const Point& aPos,
......
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