Commits

Ariel Constenla-Haile  committed e2f2a04

contextmenu1: #i117741# - framework/chart2: adapt chart2 context menus to the new XML based implementation

  • Participants
  • Parent commits 812c399

Comments (0)

Files changed (27)

File chart2/source/controller/main/ChartController_Window.cxx

         /* bCheck = */ true );
 }
 
-void lcl_insertMenuCommand(
-    const uno::Reference< awt::XPopupMenu > & xMenu,
-    const uno::Reference< awt::XMenuExtended > & xMenuEx,
-    sal_Int16 nId, const ::rtl::OUString & rCommand )
-{
-    static ::rtl::OUString aEmptyString;
-    xMenu->insertItem( nId, aEmptyString, 0, -1 );
-    xMenuEx->setCommand( nId, rCommand );
-}
-
-OUString lcl_getFormatCommandForObjectCID( const OUString& rCID )
-{
-    OUString aDispatchCommand( C2U(".uno:FormatSelection") );
-
-    ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID );
-
-    switch(eObjectType)
-    {
-        case OBJECTTYPE_DIAGRAM:
-        case OBJECTTYPE_DIAGRAM_WALL:
-            aDispatchCommand = C2U(".uno:FormatWall");
-            break;
-        case OBJECTTYPE_DIAGRAM_FLOOR:
-            aDispatchCommand = C2U(".uno:FormatFloor");
-            break;
-        case OBJECTTYPE_PAGE:
-            aDispatchCommand = C2U(".uno:FormatChartArea");
-            break;
-        case OBJECTTYPE_LEGEND:
-            aDispatchCommand = C2U(".uno:FormatLegend");
-            break;
-        case OBJECTTYPE_TITLE:
-            aDispatchCommand = C2U(".uno:FormatTitle");
-            break;
-        case OBJECTTYPE_LEGEND_ENTRY:
-            aDispatchCommand = C2U(".uno:FormatDataSeries");
-            break;
-        case OBJECTTYPE_AXIS:
-        case OBJECTTYPE_AXIS_UNITLABEL:
-            aDispatchCommand = C2U(".uno:FormatAxis");
-            break;
-        case OBJECTTYPE_GRID:
-            aDispatchCommand = C2U(".uno:FormatMajorGrid");
-            break;
-        case OBJECTTYPE_SUBGRID:
-            aDispatchCommand = C2U(".uno:FormatMinorGrid");
-            break;
-        case OBJECTTYPE_DATA_LABELS:
-            aDispatchCommand = C2U(".uno:FormatDataLabels");
-            break;
-        case OBJECTTYPE_DATA_SERIES:
-            aDispatchCommand = C2U(".uno:FormatDataSeries");
-            break;
-        case OBJECTTYPE_DATA_LABEL:
-            aDispatchCommand = C2U(".uno:FormatDataLabel");
-            break;
-        case OBJECTTYPE_DATA_POINT:
-            aDispatchCommand = C2U(".uno:FormatDataPoint");
-            break;
-        case OBJECTTYPE_DATA_AVERAGE_LINE:
-            aDispatchCommand = C2U(".uno:FormatMeanValue");
-            break;
-        case OBJECTTYPE_DATA_ERRORS:
-        case OBJECTTYPE_DATA_ERRORS_X:
-        case OBJECTTYPE_DATA_ERRORS_Y:
-        case OBJECTTYPE_DATA_ERRORS_Z:
-            aDispatchCommand = C2U(".uno:FormatYErrorBars");
-            break;
-        case OBJECTTYPE_DATA_CURVE:
-            aDispatchCommand = C2U(".uno:FormatTrendline");
-            break;
-        case OBJECTTYPE_DATA_CURVE_EQUATION:
-            aDispatchCommand = C2U(".uno:FormatTrendlineEquation");
-            break;
-        case OBJECTTYPE_DATA_STOCK_RANGE:
-            aDispatchCommand = C2U(".uno:FormatSelection");
-            break;
-        case OBJECTTYPE_DATA_STOCK_LOSS:
-            aDispatchCommand = C2U(".uno:FormatStockLoss");
-            break;
-        case OBJECTTYPE_DATA_STOCK_GAIN:
-            aDispatchCommand = C2U(".uno:FormatStockGain");
-            break;
-        default: //OBJECTTYPE_UNKNOWN
-            break;
-    }
-    return aDispatchCommand;
-}
 
 } // anonymous namespace
 
         if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() )
             impl_notifySelectionChangeListeners();
 
+        rtl::OUString aResourceURL;
+        Point aPos( rCEvt.GetMousePosPixel() );
+        if( !rCEvt.IsMouseEvent() )
+        {
+            ::vos::OGuard aGuard( Application::GetSolarMutex() );
+            if ( m_pChartWindow )
+                aPos = m_pChartWindow->GetPointerState().maPos;
+        }
+
         if ( isShapeContext() )
         {
-            uno::Reference < beans::XPropertySet > xPropSet( m_xFrame, uno::UNO_QUERY );
-            if ( xPropSet.is() )
+            aResourceURL = m_pDrawViewWrapper->IsTextEdit() ?
+                OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_SHAPE_EDIT ) )  :
+                OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_SHAPE ) );
+        }
+        else
+        {
+            ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
+            switch ( eObjectType )
             {
-                uno::Reference< frame::XLayoutManager > xLayoutManager;
-                xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ) >>= xLayoutManager;
-                if ( xLayoutManager.is() )
+                case OBJECTTYPE_PAGE:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_PAGE ) );
+                    break;
+                case OBJECTTYPE_TITLE:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_TITLE ) );
+                    break;
+                case OBJECTTYPE_LEGEND:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_LEGEND ) );
+                    break;
+                case OBJECTTYPE_LEGEND_ENTRY:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_LEGEND_ENTRY ) );
+                    break;
+                case OBJECTTYPE_DIAGRAM:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DIAGRAM ) );
+                    break;
+                case OBJECTTYPE_DIAGRAM_WALL:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DIAGRAM_WALL ) );
+                    break;
+                case OBJECTTYPE_DIAGRAM_FLOOR:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DIAGRAM_FLOOR ) );
+                    break;
+                case OBJECTTYPE_AXIS:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_AXIS ) );
+                    break;
+                case OBJECTTYPE_AXIS_UNITLABEL:
+                    break;
+                case OBJECTTYPE_GRID:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_GRID ) );
+                    break;
+                case OBJECTTYPE_SUBGRID:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_SUBGRID ) );
+                    break;
+                case OBJECTTYPE_DATA_SERIES:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DATA_SERIES ) );
+                    break;
+                case OBJECTTYPE_DATA_POINT:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DATA_POINT ) );
+                    break;
+                case OBJECTTYPE_DATA_LABELS:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DATA_LABELS ) );
+                    break;
+                case OBJECTTYPE_DATA_LABEL:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DATA_LABEL ) );
+                    break;
+                case OBJECTTYPE_DATA_ERRORS:
+                case OBJECTTYPE_DATA_ERRORS_X:
+                case OBJECTTYPE_DATA_ERRORS_Y:
+                case OBJECTTYPE_DATA_ERRORS_Z:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DATA_ERRORS_Y ) );
+                    break;
+                case OBJECTTYPE_DATA_CURVE:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DATA_CURVE ) );
+                    break;
+                case OBJECTTYPE_DATA_AVERAGE_LINE:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DATA_AVERAGE_LINE ) );
+                    break;
+                case OBJECTTYPE_DATA_CURVE_EQUATION:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DATA_CURVE_EQUATION ) );
+                    break;
+                case OBJECTTYPE_DATA_STOCK_RANGE:
+                    break;
+                case OBJECTTYPE_DATA_STOCK_LOSS:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DATA_STOCK_LOSS ) );
+                    break;
+                case OBJECTTYPE_DATA_STOCK_GAIN:
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_DATA_STOCK_GAIN ) );
+                    break;
+                //case OBJECTTYPE_SHAPE:
+                case OBJECTTYPE_UNKNOWN: // TODO Unkown == no selection?
+                    aResourceURL = OUString( RTL_CONSTASCII_USTRINGPARAM( CHART2_CONTEXTMENU_NO_SEL ) );
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        uno::Reference < beans::XPropertySet > xPropSet( m_xFrame, uno::UNO_QUERY );
+        if ( aResourceURL.getLength() && xPropSet.is() )
+        {
+            uno::Reference< frame::XLayoutManager > xLayoutManager;
+            xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ) >>= xLayoutManager;
+            if ( xLayoutManager.is() )
+            {
+                const com::sun::star::awt::Rectangle aRect( aPos.X(), aPos.Y(), 0, 0 );
+                try
                 {
-                    OUString aResourceURL = m_pDrawViewWrapper->IsTextEdit() ?
-                        OUString( RTL_CONSTASCII_USTRINGPARAM( MN_CONTEXTMENU_SHAPEEDIT ) )  :
-                        OUString( RTL_CONSTASCII_USTRINGPARAM( MN_CONTEXTMENU_SHAPE ) );
+                    xLayoutManager->executeContextMenu( aResourceURL,
+                                                        uno::Reference< awt::XWindowPeer >( m_xFrame->getContainerWindow(), uno::UNO_QUERY ),
+                                                        aRect,
+                                                        com::sun::star::awt::PopupMenuDirection::EXECUTE_DEFAULT );
 
-                    Point aPos( rCEvt.GetMousePosPixel() );
-                    if( !rCEvt.IsMouseEvent() )
-                    {
-                        ::vos::OGuard aGuard( Application::GetSolarMutex() );
-                        if ( m_pChartWindow )
-                            aPos = m_pChartWindow->GetPointerState().maPos;
-                    }
-                    const com::sun::star::awt::Rectangle aRect( aPos.X(), aPos.Y(), 0, 0 );
-
-                    try
-                    {
-                        xLayoutManager->executeContextMenu( aResourceURL,
-                                                            uno::Reference< awt::XWindowPeer >( m_xFrame->getContainerWindow(), uno::UNO_QUERY ),
-                                                            aRect,
-                                                            com::sun::star::awt::PopupMenuDirection::EXECUTE_DEFAULT );
-
-                        xLayoutManager->destroyElement(aResourceURL);
-                    }
-                    catch( const uno::Exception & ex )
-                    {
-                        ASSERT_EXCEPTION( ex );
-                    }
+                    xLayoutManager->destroyElement(aResourceURL);
+                }
+                catch( const uno::Exception & ex )
+                {
+                    ASSERT_EXCEPTION( ex );
                 }
             }
         }
-        else
-        {
-            // todo: the context menu should be specified by an xml file in uiconfig
-            uno::Reference< awt::XPopupMenu > xPopupMenu(
-                m_xCC->getServiceManager()->createInstanceWithContext(
-                    C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY );
-            uno::Reference< awt::XMenuExtended > xMenuEx( xPopupMenu, uno::UNO_QUERY );
-            if( xPopupMenu.is() && xMenuEx.is())
-            {
-                sal_Int16 nUniqueId = 1;
-                ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
-                Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( getModel() );
-
-                OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) );
-                lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, aFormatCommand );
-
-                //some commands for dataseries and points:
-                //-----
-                if( OBJECTTYPE_DATA_SERIES == eObjectType || OBJECTTYPE_DATA_POINT == eObjectType )
-                {
-                    bool bIsPoint = ( OBJECTTYPE_DATA_POINT == eObjectType );
-                    uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() );
-                    uno::Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY );
-                    Reference< chart2::XRegressionCurve > xTrendline( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt ) );
-                    bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline );
-                    Reference< chart2::XRegressionCurve > xMeanValue( RegressionCurveHelper::getMeanValueLine( xCurveCnt ) );
-                    bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries, true );
-                    bool bHasDataLabelsAtSeries = DataSeriesHelper::hasDataLabelsAtSeries( xSeries );
-                    bool bHasDataLabelsAtPoints = DataSeriesHelper::hasDataLabelsAtPoints( xSeries );
-                    bool bHasDataLabelAtPoint = false;
-                    sal_Int32 nPointIndex = -1;
-                    if( bIsPoint )
-                    {
-                        nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() );
-                        bHasDataLabelAtPoint = DataSeriesHelper::hasDataLabelAtPoint( xSeries, nPointIndex );
-                    }
-                    bool bSelectedPointIsFormatted = false;
-                    bool bHasFormattedDataPointsOtherThanSelected = false;
-
-                    Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY );
-                    if( xSeriesProperties.is() )
-                    {
-                        uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
-                        if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList )
-                        {
-                            if( aAttributedDataPointIndexList.hasElements() )
-                            {
-                                if( bIsPoint )
-                                {
-                                    ::std::vector< sal_Int32 > aIndices( ContainerHelper::SequenceToVector( aAttributedDataPointIndexList ) );
-                                    ::std::vector< sal_Int32 >::iterator aIt = ::std::find( aIndices.begin(), aIndices.end(), nPointIndex );
-                                    if( aIt != aIndices.end())
-                                        bSelectedPointIsFormatted = true;
-                                    else
-                                        bHasFormattedDataPointsOtherThanSelected = true;
-                                }
-                                else
-                                    bHasFormattedDataPointsOtherThanSelected = true;
-                            }
-                        }
-                    }
-
-                    //const sal_Int32 nIdBeforeFormat = nUniqueId;
-                    if( bIsPoint )
-                    {
-                        if( bHasDataLabelAtPoint )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabel") );
-                        if( !bHasDataLabelAtPoint )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabel") );
-                        else
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabel") );
-                        if( bSelectedPointIsFormatted )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetDataPoint"));
-
-                        xPopupMenu->insertSeparator( -1 );
-
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataSeries") );
-                    }
-
-                    Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
-                    if( xChartType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
-                    {
-                        try
-                        {
-                            Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY );
-                            if( xChartTypeProp.is() )
-                            {
-                                bool bJapaneseStyle = false;
-                                xChartTypeProp->getPropertyValue( C2U( "Japanese" ) ) >>= bJapaneseStyle;
-
-                                if( bJapaneseStyle )
-                                {
-                                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") );
-                                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") );
-                                }
-                            }
-                        }
-                        catch( const uno::Exception & ex )
-                        {
-                            ASSERT_EXCEPTION( ex );
-                        }
-                    }
-
-                    if( bHasDataLabelsAtSeries )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabels") );
-                    if( xTrendline.is() )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendline") );
-                    if( bHasEquation )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendlineEquation") );
-                    if( xMeanValue.is() )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMeanValue") );
-                    if( bHasYErrorBars )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatYErrorBars") );
-
-                    //if( nIdBeforeFormat != nUniqueId )
-                        xPopupMenu->insertSeparator( -1 );
-
-                    //const sal_Int32 nIdBeforeInsert = nUniqueId;
-
-                    if( !bHasDataLabelsAtSeries )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabels") );
-                    if( !xTrendline.is() )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendline") );
-                    else if( !bHasEquation )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation") );
-                    if( !xMeanValue.is() )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMeanValue") );
-                    if( !bHasYErrorBars )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertYErrorBars") );
-
-                    //if( nIdBeforeInsert != nUniqueId )
-                    //    xPopupMenu->insertSeparator( -1 );
-
-                    //const sal_Int32 nIdBeforeDelete = nUniqueId;
-
-                    if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabels") );
-                    if( xTrendline.is() )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendline") );
-                    if( bHasEquation )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendlineEquation") );
-                    if( xMeanValue.is() )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMeanValue") );
-                    if( bHasYErrorBars )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteYErrorBars") );
-
-                    if( bHasFormattedDataPointsOtherThanSelected )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetAllDataPoints"));
-
-                    //if( nIdBeforeDelete != nUniqueId )
-                        xPopupMenu->insertSeparator( -1 );
-
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId, C2U(".uno:ArrangeRow"));
-                    uno::Reference< awt::XPopupMenu > xArrangePopupMenu(
-                        m_xCC->getServiceManager()->createInstanceWithContext(
-                            C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY );
-                    uno::Reference< awt::XMenuExtended > xArrangeMenuEx( xArrangePopupMenu, uno::UNO_QUERY );
-                    if( xArrangePopupMenu.is() && xArrangeMenuEx.is())
-                    {
-                        sal_Int16 nSubId = nUniqueId + 1;
-                        lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId++, C2U(".uno:Forward") );
-                        lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId, C2U(".uno:Backward") );
-                        xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu );
-                        nUniqueId = nSubId;
-                    }
-                    ++nUniqueId;
-                }
-                else if( OBJECTTYPE_DATA_CURVE == eObjectType )
-                {
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendlineEquation") );
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation") );
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquationAndR2") );
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") );
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendlineEquation") );
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") );
-                }
-                else if( OBJECTTYPE_DATA_CURVE_EQUATION == eObjectType )
-                {
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") );
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") );
-                }
-
-                //some commands for axes: and grids
-                //-----
-                else if( OBJECTTYPE_AXIS  == eObjectType || OBJECTTYPE_GRID == eObjectType || OBJECTTYPE_SUBGRID == eObjectType )
-                {
-                    Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() );
-                    if( xAxis.is() && xDiagram.is() )
-                    {
-                        sal_Int32 nDimensionIndex = -1;
-                        sal_Int32 nCooSysIndex = -1;
-                        sal_Int32 nAxisIndex = -1;
-                        AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex );
-                        bool bIsSecondaryAxis = nAxisIndex!=0;
-                        bool bIsAxisVisible = AxisHelper::isAxisVisible( xAxis );
-                        bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram );
-                        bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram );
-                        bool bHasTitle = false;
-                        uno::Reference< XTitled > xTitled( xAxis, uno::UNO_QUERY );
-                        if( xTitled.is())
-                            bHasTitle = TitleHelper::getCompleteString( xTitled->getTitleObject() ).getLength()>0;
-
-                        if( OBJECTTYPE_AXIS  != eObjectType && bIsAxisVisible )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatAxis") );
-                        if( OBJECTTYPE_GRID != eObjectType && bIsMajorGridVisible && !bIsSecondaryAxis )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMajorGrid") );
-                        if( OBJECTTYPE_SUBGRID != eObjectType && bIsMinorGridVisible && !bIsSecondaryAxis )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMinorGrid") );
-
-                        xPopupMenu->insertSeparator( -1 );
-
-                        if( OBJECTTYPE_AXIS  != eObjectType && !bIsAxisVisible )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxis") );
-                        if( OBJECTTYPE_GRID != eObjectType && !bIsMajorGridVisible && !bIsSecondaryAxis )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMajorGrid") );
-                        if( OBJECTTYPE_SUBGRID != eObjectType && !bIsMinorGridVisible && !bIsSecondaryAxis )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMinorGrid") );
-                        if( !bHasTitle )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxisTitle") );
-
-                        if( bIsAxisVisible )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteAxis") );
-                        if( bIsMajorGridVisible && !bIsSecondaryAxis )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMajorGrid") );
-                        if( bIsMinorGridVisible && !bIsSecondaryAxis )
-                            lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMinorGrid") );
-                    }
-                }
-
-                if( OBJECTTYPE_DATA_STOCK_LOSS == eObjectType )
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") );
-                else if( OBJECTTYPE_DATA_STOCK_GAIN == eObjectType )
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") );
-
-                lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:TransformDialog"));
-
-                if( OBJECTTYPE_PAGE == eObjectType || OBJECTTYPE_DIAGRAM == eObjectType
-                    || OBJECTTYPE_DIAGRAM_WALL == eObjectType
-                    || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType
-                    || OBJECTTYPE_UNKNOWN == eObjectType )
-                {
-                    if( OBJECTTYPE_UNKNOWN != eObjectType )
-                        xPopupMenu->insertSeparator( -1 );
-                    bool bHasLegend = LegendHelper::hasLegend( xDiagram );
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTitles") );
-                    if( !bHasLegend )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertLegend") );
-                    lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertRemoveAxes") );
-                    if( bHasLegend )
-                        lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteLegend") );
-                }
-                //-----
-
-                xPopupMenu->insertSeparator( -1 );
-                lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramType"));
-                lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DataRanges"));
-                lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramData"));
-                lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:View3D"));
-                xPopupMenu->insertSeparator( -1 );
-                lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Cut"));
-                lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Copy"));
-                lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Paste"));
-
-                ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame );
-                Point aPos( rCEvt.GetMousePosPixel() );
-                if( !rCEvt.IsMouseEvent() )
-                {
-                    ::vos::OGuard aGuard( Application::GetSolarMutex() );
-                    if(m_pChartWindow)
-                        aPos = m_pChartWindow->GetPointerState().maPos;
-                }
-                aContextMenuHelper.completeAndExecute( aPos, xPopupMenu );
-            }
-        }
-	}
+    }
     else if( ( rCEvt.GetCommand() == COMMAND_STARTEXTTEXTINPUT ) ||
              ( rCEvt.GetCommand() == COMMAND_EXTTEXTINPUT ) ||
              ( rCEvt.GetCommand() == COMMAND_ENDEXTTEXTINPUT ) ||

File chart2/source/controller/main/ControllerCommandDispatch.cxx

 #include "DataSeriesHelper.hxx"
 #include "StatisticsHelper.hxx"
 #include "ShapeController.hxx"
+#include "ContainerHelper.hxx"
+#include <servicenames_charttypes.hxx>
 
 #include <com/sun/star/util/XModifyBroadcaster.hpp>
 #include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/chart2/XAxis.hpp>
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/chart2/XChartType.hpp>
 #include <com/sun/star/chart2/XDataSeries.hpp>
     bool bMayFormatTrendlineEquation;
     bool bMayFormatMeanValue;
     bool bMayFormatYErrorBars;
+
+    // stock range/gain/loss
+    bool bMayFormatStockGain;
+    bool bMayFormatStockLoss;
+
+    bool bMayAddDataLabel;
+    bool bMayFormatDataLabel;
+    bool bMayDeleteDataLabel;
+
+    bool bMayAddDataLabels;
+    bool bMayFormatDataLabels;
+    bool bMayDeleteDataLabels;
+
+    bool bMayFormatDataSeries;
+
+    bool bMayFormatDataPoint;
+    bool bMayResetDataPoint;
+    bool bMayResetAllDataPoints;
+
+    bool bMayAddAxis;
+    bool bMayDeleteAxis;
+    bool bMayFormatAxis;
+    bool bMayAddAxisTitle;
+
+    bool bMayAddMajorGrid;
+    bool bMayFormatMajorGrid;
+    bool bMayDeleteMajorGrid;
+
+    bool bMayAddMinorGrid;
+    bool bMayFormatMinorGrid;
+    bool bMayDeleteMinorGrid;
+    
+    bool bMayFormatTitle; // TODO: redundant? see bIsTextObject = OBJECTTYPE_TITLE == aObjectType
 };
 
 
         bMayFormatTrendline( false ),
         bMayFormatTrendlineEquation( false ),
         bMayFormatMeanValue( false ),
-        bMayFormatYErrorBars( false )
+        bMayFormatYErrorBars( false ),
+        bMayFormatStockGain( false ),
+        bMayFormatStockLoss( false ),
+        bMayAddDataLabel( false ),
+        bMayFormatDataLabel( false ),
+        bMayDeleteDataLabel( false ),
+        bMayAddDataLabels( false ),
+        bMayFormatDataLabels( false ),
+        bMayDeleteDataLabels( false ),
+        bMayFormatDataSeries( false ),
+        bMayFormatDataPoint( false ),
+        bMayResetDataPoint( false ),
+        bMayResetAllDataPoints( false ),
+        bMayAddAxis( false ),
+        bMayDeleteAxis( false ),
+        bMayFormatAxis( false ),
+        bMayAddAxisTitle( false ),
+        bMayAddMajorGrid( false ),
+        bMayFormatMajorGrid( false ),
+        bMayDeleteMajorGrid( false ),
+        bMayAddMinorGrid( false ),
+        bMayFormatMinorGrid( false ),
+        bMayDeleteMinorGrid( false ),
+        bMayFormatTitle( false )
 {}
 
 void ControllerState::update(
         xController, uno::UNO_QUERY );
 
     // Update ControllerState variables.
-    if( xSelectionSupplier.is())
+    if( !xSelectionSupplier.is() )
+        return;
+
+    uno::Any aSelObj( xSelectionSupplier->getSelection() );
+    ObjectIdentifier aSelOID( aSelObj );
+    OUString aSelObjCID( aSelOID.getObjectCID() );
+    ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID ));
+    uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ));
+
+    // State variables
+    bHasSelectedObject = aSelOID.isValid();
+    bIsPositionableObject = (OBJECTTYPE_DATA_POINT != aObjectType) && aSelOID.isDragableObject();
+    bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj );
+    bIsFormateableObjectSelected = bHasSelectedObject && aSelOID.isAutoGeneratedObject();
+
+
+    // TODO if there is no selection available, all should be set to false
+    // that is, do all these asignment above, BEFORE checking if !xSelectionSupplier.is()
+    bMayMoveSeriesForward = false;
+    bMayMoveSeriesBackward = false;
+
+    bMayAddTrendline = false;
+    bMayAddTrendlineEquation = false;
+    bMayAddR2Value = false;
+    bMayAddMeanValue = false;
+    bMayAddYErrorBars = false;
+    bMayDeleteTrendline = false;
+    bMayDeleteTrendlineEquation = false;
+    bMayDeleteR2Value = false;
+    bMayDeleteMeanValue = false;
+    bMayDeleteYErrorBars = false;
+    bMayFormatTrendline = false;
+    bMayFormatTrendlineEquation = false;
+    bMayFormatMeanValue = false;
+    bMayFormatYErrorBars = false;
+    bMayFormatStockGain = false;
+    bMayFormatStockLoss = false;
+    bMayAddDataLabel = false;
+    bMayFormatDataLabel = false;
+    bMayDeleteDataLabel = false;
+    bMayAddDataLabels = false;
+    bMayFormatDataLabels = false;
+    bMayDeleteDataLabels = false;
+    bMayFormatDataSeries = false;
+    bMayFormatDataPoint = false;
+    bMayResetDataPoint = false;
+    bMayResetAllDataPoints = false;
+    bMayAddAxis = false;
+    bMayDeleteAxis = false;
+    bMayFormatAxis = false;
+    bMayAddAxisTitle = false;
+    bMayAddMajorGrid = false;
+    bMayFormatMajorGrid = false;
+    bMayDeleteMajorGrid = false;
+    bMayAddMinorGrid = false;
+    bMayFormatMinorGrid = false;
+    bMayDeleteMinorGrid = false;
+    bMayFormatTitle = false;
+
+    if( !bHasSelectedObject )
+        return;
+
+    switch ( aObjectType )
     {
-        uno::Any aSelObj( xSelectionSupplier->getSelection() );
-        ObjectIdentifier aSelOID( aSelObj );
-        OUString aSelObjCID( aSelOID.getObjectCID() );
+        case OBJECTTYPE_DIAGRAM:
+        case OBJECTTYPE_DIAGRAM_WALL:
+        case OBJECTTYPE_DIAGRAM_FLOOR:
+            bIsFormateableObjectSelected = DiagramHelper::isSupportingFloorAndWall( xDiagram );
+            break;
+        /*case OBJECTTYPE_PAGE:
+            bMayFormatChartArea = true; TODO is it enough to get the state from the Model State if bIsWritable?
+            break;*/
+        case OBJECTTYPE_DATA_LABEL:
+            bMayFormatDataLabel = true;
+            break;
+        case OBJECTTYPE_DATA_LABELS:
+            bMayFormatDataLabels = true;
+            break;
+        case OBJECTTYPE_LEGEND_ENTRY:
+            bMayFormatDataSeries = true;
+            break;
+        case OBJECTTYPE_DATA_SERIES:
+        case OBJECTTYPE_DATA_POINT:
+            {
+                bMayFormatDataSeries = true;
 
-        bHasSelectedObject = aSelOID.isValid();
+                uno::Reference< chart2::XDataSeries > xGivenDataSeries(
+                    ObjectIdentifier::getDataSeriesForCID( aSelObjCID, xModel ) );
+                if ( !xGivenDataSeries.is() )
+                    break;
 
-        ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID ));
-
-        bIsPositionableObject = (OBJECTTYPE_DATA_POINT != aObjectType) && aSelOID.isDragableObject();
-        bIsTextObject = OBJECTTYPE_TITLE == aObjectType;
-
-        uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ));
-        bIsFormateableObjectSelected = bHasSelectedObject && aSelOID.isAutoGeneratedObject();
-        if( OBJECTTYPE_DIAGRAM==aObjectType || OBJECTTYPE_DIAGRAM_WALL==aObjectType || OBJECTTYPE_DIAGRAM_FLOOR==aObjectType )
-            bIsFormateableObjectSelected = DiagramHelper::isSupportingFloorAndWall( xDiagram );
-
-        uno::Reference< chart2::XDataSeries > xGivenDataSeries(
-            ObjectIdentifier::getDataSeriesForCID(
-                aSelObjCID, xModel ) );
-
-        bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj );
-
-        bMayMoveSeriesForward = (OBJECTTYPE_DATA_POINT!=aObjectType) && DiagramHelper::isSeriesMoveable(
-            ChartModelHelper::findDiagram( xModel ),
-            xGivenDataSeries,
-            MOVE_SERIES_FORWARD );
-
-        bMayMoveSeriesBackward = (OBJECTTYPE_DATA_POINT!=aObjectType) && DiagramHelper::isSeriesMoveable(
-            ChartModelHelper::findDiagram( xModel ),
-            xGivenDataSeries,
-            MOVE_SERIES_BACKWARD );
-
-        bMayAddTrendline = false;
-        bMayAddTrendlineEquation = false;
-        bMayAddR2Value = false;
-        bMayAddMeanValue = false;
-        bMayAddYErrorBars = false;
-        bMayDeleteTrendline = false;
-        bMayDeleteTrendlineEquation = false;
-        bMayDeleteR2Value = false;
-        bMayDeleteMeanValue = false;
-        bMayDeleteYErrorBars = false;
-        bMayFormatTrendline = false;
-        bMayFormatTrendlineEquation = false;
-        bMayFormatMeanValue = false;
-        bMayFormatYErrorBars = false;
-        if( bHasSelectedObject )
-        {
-            if( xGivenDataSeries.is())
-            {
                 sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
                 uno::Reference< chart2::XChartType > xFirstChartType(
                     DataSeriesHelper::getChartTypeOfSeries( xGivenDataSeries, xDiagram ));
 
                 // trend lines/mean value line
-                if( (OBJECTTYPE_DATA_SERIES == aObjectType || OBJECTTYPE_DATA_POINT == aObjectType)
-                    && ChartTypeHelper::isSupportingRegressionProperties( xFirstChartType, nDimensionCount ))
+                if ( ChartTypeHelper::isSupportingRegressionProperties( xFirstChartType, nDimensionCount ) )
                 {
-                    uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
-                        xGivenDataSeries, uno::UNO_QUERY );
+                    uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xGivenDataSeries, uno::UNO_QUERY );
                     if( xRegCurveCnt.is())
                     {
-                        uno::Reference< chart2::XRegressionCurve > xRegCurve( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) );
-                        bMayFormatTrendline = bMayDeleteTrendline = xRegCurve.is();
-                        bMayFormatMeanValue = bMayDeleteMeanValue = RegressionCurveHelper::hasMeanValueLine( xRegCurveCnt );
-                        bMayAddTrendline = ! bMayDeleteTrendline;
-                        bMayAddMeanValue = ! bMayDeleteMeanValue;
-                        bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = RegressionCurveHelper::hasEquation( xRegCurve );
-                        bMayAddTrendlineEquation = !bMayDeleteTrendlineEquation;
+                        // tend line / equation
+                        Reference< chart2::XRegressionCurve > xTrendline( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) );
+                        bool bHasEquation = xTrendline.is() && RegressionCurveHelper::hasEquation( xTrendline ); 
+                        bMayFormatTrendline = bMayDeleteTrendline = xTrendline.is();
+                        bMayAddTrendline = !bMayDeleteTrendline;
+                        bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = bHasEquation;
+                        bMayAddTrendlineEquation = xTrendline.is() && !bHasEquation;
+
+                        // mean value
+                        Reference< chart2::XRegressionCurve > xMeanValue( RegressionCurveHelper::getMeanValueLine( xRegCurveCnt ) );
+                        bMayFormatMeanValue = bMayDeleteMeanValue = xMeanValue.is();
+                        bMayAddMeanValue = !bMayDeleteMeanValue;
                     }
                 }
 
                 // error bars
-                if( (OBJECTTYPE_DATA_SERIES == aObjectType || OBJECTTYPE_DATA_POINT == aObjectType)
-                    && ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount ))
+                if( ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount ))
                 {
                     bMayFormatYErrorBars = bMayDeleteYErrorBars = StatisticsHelper::hasErrorBars( xGivenDataSeries );
                     bMayAddYErrorBars = ! bMayDeleteYErrorBars;
                 }
-            }
 
-            if( aObjectType == OBJECTTYPE_DATA_AVERAGE_LINE )
-                bMayFormatMeanValue = true;
+                // Stock Gain/Loss for Japanese CandleStick
+                if ( xFirstChartType->getChartType().equals( CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) )
+                {
+                    try
+                    {
+                        Reference< beans::XPropertySet > xChartTypeProp( xFirstChartType, uno::UNO_QUERY );
+                        if( xChartTypeProp.is() )
+                        {
+                            bool bJapaneseStyle = false;
+                            if( xChartTypeProp->getPropertyValue( C2U( "Japanese" ) ) >>= bJapaneseStyle )
+                                bMayFormatStockGain = bMayFormatStockLoss = bJapaneseStyle;
+                        }
+                    }
+                    catch ( const uno::Exception & ex )
+                    {
+                        ASSERT_EXCEPTION( ex );
+                    }
+                }
 
-            if( aObjectType == OBJECTTYPE_DATA_ERRORS_Y || aObjectType == OBJECTTYPE_DATA_ERRORS )
-                bMayFormatYErrorBars = true;
+                // DataLabel/s - DataPoint/s - DataSeries
+                bool bHasDataLabelsAtSeries = DataSeriesHelper::hasDataLabelsAtSeries( xGivenDataSeries );
+                bool bHasDataLabelsAtPoints = DataSeriesHelper::hasDataLabelsAtPoints( xGivenDataSeries );
 
-            if( aObjectType == OBJECTTYPE_DATA_CURVE )
+                uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
+                Reference< beans::XPropertySet > xSeriesProperties( xGivenDataSeries, uno::UNO_QUERY );
+                if ( xSeriesProperties.is() )
+                {
+                    try
+                    {
+                        xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList;
+                    }
+                    catch ( ... ) {}
+                }
+                bool bHasFormattedDataPointsOtherThenSelected = false;
+
+                if (  OBJECTTYPE_DATA_POINT == aObjectType)
+                {
+                    bMayFormatDataPoint = true;
+
+                    sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( aSelObjCID );
+                    bool bHasDataLabelAtPoint = DataSeriesHelper::hasDataLabelAtPoint( xGivenDataSeries, nPointIndex );
+
+                    bool bSelectedPointIsFormatted = false;
+                    if ( aAttributedDataPointIndexList.hasElements() )
+                    {
+                        std::vector< sal_Int32 > aIndices( ContainerHelper::SequenceToVector( aAttributedDataPointIndexList ) );
+                        std::vector< sal_Int32 >::iterator aIt = std::find( aIndices.begin(), aIndices.end(), nPointIndex );
+                        if ( aIt != aIndices.end() )
+                            bSelectedPointIsFormatted = true;
+                        else
+                            bHasFormattedDataPointsOtherThenSelected = true;
+                    }
+
+                    bMayAddDataLabel = !bHasDataLabelAtPoint;
+                    bMayFormatDataLabel = bMayDeleteDataLabel = bHasDataLabelAtPoint;
+                    bMayResetDataPoint = bSelectedPointIsFormatted;
+                }
+                else // OBJECTTYPE_DATA_SERIES only
+                {
+                    bHasFormattedDataPointsOtherThenSelected = aAttributedDataPointIndexList.hasElements();
+
+                    bMayMoveSeriesForward = DiagramHelper::isSeriesMoveable(
+                            xDiagram/*ChartModelHelper::findDiagram( xModel )*/,
+                            xGivenDataSeries,
+                            MOVE_SERIES_FORWARD );
+
+                    bMayMoveSeriesBackward = DiagramHelper::isSeriesMoveable(
+                            xDiagram/*ChartModelHelper::findDiagram( xModel )*/,
+                            xGivenDataSeries,
+                            MOVE_SERIES_BACKWARD );
+                }
+
+                bMayAddDataLabels = !bHasDataLabelsAtSeries/* || !bHasDataLabelsAtPoints*/;
+                bMayFormatDataLabels = bHasDataLabelsAtSeries/* || bHasDataLabelsAtPoints*/;
+                bMayDeleteDataLabels = bHasDataLabelsAtSeries 
+                    || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThenSelected );
+                bMayResetAllDataPoints = bHasFormattedDataPointsOtherThenSelected;
+
+            } // OBJECTTYPE_DATA_SERIES / OBJECTTYPE_DATA_POINT
+            break;
+        case OBJECTTYPE_DATA_AVERAGE_LINE:
+            bMayFormatMeanValue = true;
+            break;
+        case OBJECTTYPE_DATA_ERRORS:
+        case OBJECTTYPE_DATA_ERRORS_X:
+        case OBJECTTYPE_DATA_ERRORS_Y:
+        case OBJECTTYPE_DATA_ERRORS_Z:
+            bMayFormatYErrorBars = true;
+            break;
+        case OBJECTTYPE_DATA_CURVE:
             {
                 bMayFormatTrendline = true;
                 uno::Reference< chart2::XRegressionCurve > xRegCurve(
                 bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = RegressionCurveHelper::hasEquation( xRegCurve );
                 bMayAddTrendlineEquation = !bMayDeleteTrendlineEquation;
             }
-            else if( aObjectType == OBJECTTYPE_DATA_CURVE_EQUATION )
+            break;
+        case OBJECTTYPE_DATA_CURVE_EQUATION:
             {
                 bMayFormatTrendlineEquation = true;
                 bool bHasR2Value = false;
                 bMayAddR2Value = !bHasR2Value;
                 bMayDeleteR2Value = bHasR2Value;
             }
-        }
+            break;
+        case OBJECTTYPE_DATA_STOCK_RANGE:
+            break;
+        case OBJECTTYPE_DATA_STOCK_LOSS:
+            {
+                bMayFormatStockLoss = true;
+                bMayFormatStockGain = true;
+            }
+            break;
+        case OBJECTTYPE_DATA_STOCK_GAIN:
+            {
+                bMayFormatStockGain = true;
+                bMayFormatStockLoss = true;
+            }
+            break;
+        case OBJECTTYPE_AXIS_UNITLABEL:
+            bMayFormatAxis = true;
+            break; //TODO treat this as AXIS?
+        case OBJECTTYPE_AXIS:
+        case OBJECTTYPE_GRID:
+        case OBJECTTYPE_SUBGRID:
+            {
+                Reference< chart2::XAxis > xAxis = ObjectIdentifier::getAxisForCID( aSelObjCID, xModel );
+                if( xAxis.is() && xDiagram.is() )
+                {
+                    sal_Int32 nDimensionIndex = -1;
+                    sal_Int32 nCooSysIndex = -1;
+                    sal_Int32 nAxisIndex = -1;
+
+                    AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex );
+
+                    bool bIsSecondaryAxis    = nAxisIndex!=0;
+                    bool bIsAxisVisible      = AxisHelper::isAxisVisible( xAxis );
+                    bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram );
+                    bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram );
+
+                    bool bHasTitle = false;
+                    uno::Reference< chart2::XTitled > xTitled( xAxis, uno::UNO_QUERY );
+                    if( xTitled.is() )
+                         bHasTitle = TitleHelper::getCompleteString( xTitled->getTitleObject() ).getLength()>0;
+                    bMayAddAxisTitle = !bHasTitle;
+
+                    if ( OBJECTTYPE_AXIS  == aObjectType )
+                        bMayFormatAxis = true;
+                    else
+                        bMayFormatAxis = bIsAxisVisible;
+
+                    if ( OBJECTTYPE_AXIS  != aObjectType && !bIsAxisVisible )
+                        bMayAddAxis = true;
+
+                    if ( OBJECTTYPE_GRID == aObjectType )
+                        bMayFormatMajorGrid = true;
+                    else
+                        bMayFormatMajorGrid = bIsMajorGridVisible && !bIsSecondaryAxis;
+
+                    if( OBJECTTYPE_GRID != aObjectType && !bIsMajorGridVisible && !bIsSecondaryAxis )
+                        bMayAddMajorGrid = true;
+
+                    if ( OBJECTTYPE_SUBGRID == aObjectType )
+                        bMayFormatMinorGrid = true;
+                    else
+                        bMayFormatMinorGrid = bIsMinorGridVisible && !bIsSecondaryAxis;
+
+                    if( OBJECTTYPE_SUBGRID != aObjectType && !bIsMinorGridVisible && !bIsSecondaryAxis )
+                        bMayAddMinorGrid = true;
+
+                    bMayDeleteAxis = bIsAxisVisible;
+                    bMayDeleteMajorGrid = bIsMajorGridVisible && !bIsSecondaryAxis;
+                    bMayDeleteMinorGrid = bIsMinorGridVisible && !bIsSecondaryAxis;
+                }
+            }
+            break;
+        case OBJECTTYPE_TITLE:
+            {
+                bMayFormatTitle = true;
+                bIsTextObject = true;
+            }
+            break;
+        default:
+            break;
     }
 }
 
 
+
 /** Represents the current state of the model.
 
     You can set the state by calling update().  After this call the state is
         bHasFloor( false ),
         bSupportsStatistics( false ),
         bSupportsAxes( false )
-
 {}
 
 void ModelState::update( const Reference< frame::XModel > & xModel )
 
     // insert objects
     m_aCommandAvailability[ C2U(".uno:InsertTitles")] = m_aCommandAvailability[ C2U(".uno:InsertMenuTitles")] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:InsertLegend")] = m_aCommandAvailability[ C2U(".uno:InsertMenuLegend")] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:DeleteLegend")] = bIsWritable;
+
+    // insert/delete Legend
+    m_aCommandAvailability[ C2U(".uno:InsertMenuLegend")] = bIsWritable;
+    m_aCommandAvailability[ C2U(".uno:InsertLegend")] = bIsWritable && !m_apModelState->bHasLegend;
+    m_aCommandAvailability[ C2U(".uno:DeleteLegend")] = bIsWritable && m_apModelState->bHasLegend;
+
     m_aCommandAvailability[ C2U(".uno:InsertMenuDataLabels")] = bIsWritable;
     m_aCommandAvailability[ C2U(".uno:InsertRemoveAxes")] = m_aCommandAvailability[ C2U(".uno:InsertMenuAxes")] = bIsWritable && m_apModelState->bSupportsAxes;
     m_aCommandAvailability[ C2U(".uno:InsertMenuGrids")] = bIsWritable && m_apModelState->bSupportsAxes;
     // format objects
     bool bFormatObjectAvailable = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsFormateableObjectSelected;
     m_aCommandAvailability[ C2U(".uno:FormatSelection")] = bFormatObjectAvailable;
-    m_aCommandAvailability[ C2U(".uno:FormatAxis")] = bFormatObjectAvailable;
-    m_aCommandAvailability[ C2U(".uno:FormatTitle")] = bFormatObjectAvailable;
-    m_aCommandAvailability[ C2U(".uno:FormatDataSeries")] = bFormatObjectAvailable;
-    m_aCommandAvailability[ C2U(".uno:FormatDataPoint")] = bFormatObjectAvailable;
-    m_aCommandAvailability[ C2U(".uno:FormatDataLabels")] = bFormatObjectAvailable;
-    m_aCommandAvailability[ C2U(".uno:FormatDataLabel")] = bFormatObjectAvailable;
+    m_aCommandAvailability[ C2U(".uno:FormatAxis")] = bFormatObjectAvailable && m_apControllerState->bMayFormatAxis;
+    m_aCommandAvailability[ C2U(".uno:FormatTitle")] = bFormatObjectAvailable && m_apControllerState->bMayFormatTitle;
+    m_aCommandAvailability[ C2U(".uno:FormatDataSeries")] = bFormatObjectAvailable && m_apControllerState->bMayFormatDataSeries;
+    m_aCommandAvailability[ C2U(".uno:FormatDataPoint")] = bFormatObjectAvailable && m_apControllerState->bMayFormatDataPoint;
+    m_aCommandAvailability[ C2U(".uno:FormatDataLabels")] = bFormatObjectAvailable && m_apControllerState->bMayFormatDataLabels;
+    m_aCommandAvailability[ C2U(".uno:FormatDataLabel")] = bFormatObjectAvailable && m_apControllerState->bMayFormatDataLabel;
     m_aCommandAvailability[ C2U(".uno:FormatYErrorBars")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatYErrorBars;
     m_aCommandAvailability[ C2U(".uno:FormatMeanValue")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatMeanValue;
     m_aCommandAvailability[ C2U(".uno:FormatTrendline")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendline;
-    m_aCommandAvailability[ C2U(".uno:FormatTrendlineEquation")] = bFormatObjectAvailable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendlineEquation;
-    m_aCommandAvailability[ C2U(".uno:FormatStockLoss")] = bFormatObjectAvailable;
-    m_aCommandAvailability[ C2U(".uno:FormatStockGain")] = bFormatObjectAvailable;
+    m_aCommandAvailability[ C2U(".uno:FormatTrendlineEquation")] = bFormatObjectAvailable && m_apControllerState->bMayFormatTrendlineEquation;
+    m_aCommandAvailability[ C2U(".uno:FormatStockLoss")] = bFormatObjectAvailable && m_apControllerState->bMayFormatStockLoss;
+    m_aCommandAvailability[ C2U(".uno:FormatStockGain")] = bFormatObjectAvailable && m_apControllerState->bMayFormatStockGain;
 
     m_aCommandAvailability[ C2U(".uno:DiagramType")] = bIsWritable;
     m_aCommandAvailability[ C2U(".uno:Legend")] = bIsWritable && m_apModelState->bHasLegend;
     m_aCommandAvailability[ C2U(".uno:DiagramFloor")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasFloor;
 
     //some mor format commands with different ui text
+    // TODO get them all from the Controller State?
     m_aCommandAvailability[ C2U(".uno:FormatWall")] = m_aCommandAvailability[ C2U(".uno:DiagramWall")];
     m_aCommandAvailability[ C2U(".uno:FormatFloor")] = m_aCommandAvailability[ C2U(".uno:DiagramFloor")];
     m_aCommandAvailability[ C2U(".uno:FormatChartArea")] = m_aCommandAvailability[ C2U(".uno:DiagramArea")];
     m_aCommandAvailability[ C2U(".uno:Backward")] = ( bShapeContext ? isShapeControllerCommandAvailable( C2U( ".uno:Backward" ) ) :
         ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward && !bDisableDataTableDialog ) );
 
-    m_aCommandAvailability[ C2U(".uno:InsertDataLabels")] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:InsertDataLabel")] = bIsWritable;
+    m_aCommandAvailability[ C2U(".uno:InsertDataLabels")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddDataLabels;
+    m_aCommandAvailability[ C2U(".uno:InsertDataLabel")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddDataLabel;
     m_aCommandAvailability[ C2U(".uno:InsertMeanValue")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddMeanValue;
     m_aCommandAvailability[ C2U(".uno:InsertTrendline")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendline;
     m_aCommandAvailability[ C2U(".uno:InsertTrendlineEquation")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendlineEquation;
 
     m_aCommandAvailability[ C2U(".uno:InsertYErrorBars")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddYErrorBars;
 
-    m_aCommandAvailability[ C2U(".uno:DeleteDataLabels")] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:DeleteDataLabel") ] = bIsWritable;
+    m_aCommandAvailability[ C2U(".uno:DeleteDataLabels")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteDataLabels;
+    m_aCommandAvailability[ C2U(".uno:DeleteDataLabel") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteDataLabel;
     m_aCommandAvailability[ C2U(".uno:DeleteTrendline") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendline;
     m_aCommandAvailability[ C2U(".uno:DeleteTrendlineEquation") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendlineEquation;
     m_aCommandAvailability[ C2U(".uno:DeleteMeanValue") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteMeanValue;
     m_aCommandAvailability[ C2U(".uno:DeleteYErrorBars") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteYErrorBars;
 
-    m_aCommandAvailability[ C2U(".uno:ResetDataPoint") ] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:ResetAllDataPoints") ] = bIsWritable;
+    m_aCommandAvailability[ C2U(".uno:ResetDataPoint") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayResetDataPoint;
+    m_aCommandAvailability[ C2U(".uno:ResetAllDataPoints") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayResetAllDataPoints;
 
-    m_aCommandAvailability[ C2U(".uno:InsertAxis") ] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:DeleteAxis") ] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:InsertAxisTitle") ] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:FormatMajorGrid") ] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:InsertMajorGrid") ] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:DeleteMajorGrid") ] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:FormatMinorGrid") ] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:InsertMinorGrid") ] = bIsWritable;
-    m_aCommandAvailability[ C2U(".uno:DeleteMinorGrid") ] = bIsWritable;
+    m_aCommandAvailability[ C2U(".uno:InsertAxis") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddAxis;
+    m_aCommandAvailability[ C2U(".uno:DeleteAxis") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteAxis;
+    m_aCommandAvailability[ C2U(".uno:InsertAxisTitle") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddAxisTitle;
+    m_aCommandAvailability[ C2U(".uno:FormatMajorGrid") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatMajorGrid;
+    m_aCommandAvailability[ C2U(".uno:InsertMajorGrid") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddMajorGrid;
+    m_aCommandAvailability[ C2U(".uno:DeleteMajorGrid") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteMajorGrid;
+    m_aCommandAvailability[ C2U(".uno:FormatMinorGrid") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatMinorGrid;
+    m_aCommandAvailability[ C2U(".uno:InsertMinorGrid") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddMinorGrid;
+    m_aCommandAvailability[ C2U(".uno:DeleteMinorGrid") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteMinorGrid;
 }
 
 bool ControllerCommandDispatch::commandAvailable( const OUString & rCommand )
     ::std::map< OUString, bool >::const_iterator aIt( m_aCommandAvailability.find( rCommand ));
     if( aIt != m_aCommandAvailability.end())
         return aIt->second;
+    OSL_TRACE( "ControllerCommandDispatch::commandAvailable - \"%s\" not in availability map", U2C( rCommand ) );
     OSL_ENSURE( false, "commandAvailable: command not in availability map" );
     return false;
 }

File chart2/source/controller/main/DrawCommandDispatch.cxx

 {
     FeatureState aReturn;
     aReturn.bEnabled = false;
-    aReturn.aState <<= false;
 
     sal_uInt16 nFeatureId = 0;
     ::rtl::OUString aBaseCommand;
             case COMMAND_ID_DRAWTBX_CS_STAR:
                 {
                     aReturn.bEnabled = true;
-                    aReturn.aState <<= false;
                 }
                 break;
             default:
-                {
-                    aReturn.bEnabled = false;
-                    aReturn.aState <<= false;
-                }
                 break;
         }
     }

File chart2/source/controller/main/ShapeController.cxx

 {
     FeatureState aReturn;
     aReturn.bEnabled = false;
-    // Setting aState as a boolean by default, will send a wrong feature state
-    // to the ContextMenuManager, that will make the item checkable (Checkmark or RadioButton)
-    // aReturn.aState <<= false; leave it as an empty Any
 
     bool bWritable = false;
     if ( m_pChartController )
             case COMMAND_ID_TRANSFORM_DIALOG:
                 {
                     aReturn.bEnabled = bWritable;
-                    aReturn.aState <<= false;
                 }
                 break;
             case COMMAND_ID_BRING_TO_FRONT:
             case COMMAND_ID_FORWARD:
                 {
                     aReturn.bEnabled = ( bWritable && isForwardPossible() );
-                    aReturn.aState <<= false;
                 }
                 break;
             case COMMAND_ID_BACKWARD:
                 {
 
                     aReturn.bEnabled = ( bWritable && isBackwardPossible() );
-                    aReturn.aState <<= false;
                 }
                 break;
             case COMMAND_ID_FONT_DIALOG:
             case COMMAND_ID_PARAGRAPH_DIALOG:
                 {
                     aReturn.bEnabled = bWritable;
-                    aReturn.aState <<= false;
                 }
                 break;
             default:
-                {
-                    aReturn.bEnabled = false;
-                    aReturn.aState <<= false;
-                }
                 break;
         }
     }

File chart2/source/controller/main/contextmenu.hxx

  *
  ************************************************************************/
 
-#ifndef _CHART2_CONTEXTMENU_HXX
-#define _CHART2_CONTEXTMENU_HXX
+#ifndef CHART2_CONTEXTMENU_HXX
+#define CHART2_CONTEXTMENU_HXX
 
-#define MN_CONTEXTMENU_SHAPE      "private:resource/contextmenu/shape"
-#define MN_CONTEXTMENU_SHAPEEDIT  "private:resource/contextmenu/shapeedit"
+#define CHART2_CONTEXTMENU_PAGE                 "private:resource/contextmenu/area"
+#define CHART2_CONTEXTMENU_AXIS                 "private:resource/contextmenu/axis"
+#define CHART2_CONTEXTMENU_DIAGRAM              "private:resource/contextmenu/chart"
+#define CHART2_CONTEXTMENU_DATA_LABEL           "private:resource/contextmenu/datalabel"
+#define CHART2_CONTEXTMENU_DATA_LABELS          "private:resource/contextmenu/datalabels"
+#define CHART2_CONTEXTMENU_DATA_POINT           "private:resource/contextmenu/datapoint"
+#define CHART2_CONTEXTMENU_DATA_SERIES          "private:resource/contextmenu/dataseries"
+#define CHART2_CONTEXTMENU_DIAGRAM_FLOOR        "private:resource/contextmenu/floor"
+#define CHART2_CONTEXTMENU_LEGEND               "private:resource/contextmenu/legend"
+#define CHART2_CONTEXTMENU_LEGEND_ENTRY         "private:resource/contextmenu/legendkey"
+#define CHART2_CONTEXTMENU_GRID                 "private:resource/contextmenu/mayorgrid"
+#define CHART2_CONTEXTMENU_DATA_AVERAGE_LINE    "private:resource/contextmenu/meanvalueline"
+#define CHART2_CONTEXTMENU_SUBGRID              "private:resource/contextmenu/minorgrid"
+#define CHART2_CONTEXTMENU_NO_SEL               "private:resource/contextmenu/nosel"
+#define CHART2_CONTEXTMENU_SHAPE                "private:resource/contextmenu/shape"
+#define CHART2_CONTEXTMENU_SHAPE_EDIT           "private:resource/contextmenu/shapeedit"
+#define CHART2_CONTEXTMENU_DATA_STOCK_GAIN      "private:resource/contextmenu/stockgain"
+#define CHART2_CONTEXTMENU_DATA_STOCK_LOSS      "private:resource/contextmenu/stockloss"
+#define CHART2_CONTEXTMENU_TITLE                "private:resource/contextmenu/title"
+#define CHART2_CONTEXTMENU_DATA_CURVE           "private:resource/contextmenu/trendline"
+#define CHART2_CONTEXTMENU_DATA_CURVE_EQUATION  "private:resource/contextmenu/trendlnequation"
+#define CHART2_CONTEXTMENU_DIAGRAM_WALL         "private:resource/contextmenu/wall"
+#define CHART2_CONTEXTMENU_DATA_ERRORS_Y        "private:resource/contextmenu/yerrorbars"
 
-#endif // _CHART2_CONTEXTMENU_HXX
+#endif // CHART2_CONTEXTMENU_HXX

File chart2/uiconfig/contextmenu/area.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatChartArea"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:InsertTitles"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertRemoveAxes"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertLegend"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteLegend"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <!--TODO remove unused ".uno:Cut"/-->
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/axis.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatAxis"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatMajorGrid"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatMinorGrid"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:InsertMajorGrid"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertMinorGrid"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertAxisTitle"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteAxis"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteMajorGrid"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteMinorGrid"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/chart.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatWall"/>
+  <contextmenu:menuitem xlink:href=".uno:TransformDialog"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:InsertTitles"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertRemoveAxes"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertLegend"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteLegend"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <!--TODO remove unused ".uno:Cut"/-->
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/datalabel.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatDataLabel"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/datalabels.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatDataLabels"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/datapoint.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatDataPoint"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatDataLabel"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertDataLabel"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteDataLabel"/>
+  <contextmenu:menuitem xlink:href=".uno:ResetDataPoint"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:FormatDataSeries"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatStockLoss"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatStockGain"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatDataLabels"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatTrendline"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatTrendlineEquation"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatMeanValue"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatYErrorBars"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:InsertDataLabels"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertTrendline"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertTrendlineEquation"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertMeanValue"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertYErrorBars"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteDataLabels"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteTrendline"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteTrendlineEquation"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteMeanValue"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteYErrorBars"/>
+  <contextmenu:menuitem xlink:href=".uno:ResetAllDataPoints"/>
+  <!--contextmenu:menuitem xlink:href=".uno:ArrangeRow"/-->
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <!--TODO remove unused ".uno:Cut"/-->
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/dataseries.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatDataSeries"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatStockLoss"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatStockGain"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatDataLabels"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatTrendline"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatTrendlineEquation"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatMeanValue"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatYErrorBars"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:InsertDataLabels"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertTrendline"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertTrendlineEquation"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertMeanValue"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertYErrorBars"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteDataLabels"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteTrendline"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteTrendlineEquation"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteMeanValue"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteYErrorBars"/>
+  <contextmenu:menuitem xlink:href=".uno:ResetAllDataPoints"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menu xlink:href=".uno:ArrangeRow">
+   <contextmenu:menupopup>
+    <contextmenu:menuitem xlink:href=".uno:Forward"/>
+    <contextmenu:menuitem xlink:href=".uno:Backward"/>
+   </contextmenu:menupopup>
+  </contextmenu:menu>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/floor.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatFloor"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:InsertTitles"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertRemoveAxes"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertLegend"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteLegend"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <!--TODO remove unused ".uno:Cut"/-->
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/legend.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatLegend"/>
+  <contextmenu:menuitem xlink:href=".uno:TransformDialog"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/legendkey.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatDataSeries"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/mayorgrid.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatMajorGrid"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatAxis"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatMinorGrid"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:InsertAxis"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertMinorGrid"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertAxisTitle"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteAxis"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteMajorGrid"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteMinorGrid"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/meanvalueline.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatMeanValue"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/minorgrid.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatMinorGrid"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatAxis"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatMajorGrid"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:InsertAxis"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertMajorGrid"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertAxisTitle"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteAxis"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteMajorGrid"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteMinorGrid"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/nosel.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:InsertTitles"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertRemoveAxes"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertLegend"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteLegend"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <!--TODO remove unused ".uno:Cut"/-->
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/stockgain.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatStockGain"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatStockLoss"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <!--TODO remove unused ".uno:Cut"/-->
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/stockloss.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatStockLoss"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatStockGain"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <!--TODO remove unused ".uno:Cut"/-->
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/title.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatTitle"/>
+  <contextmenu:menuitem xlink:href=".uno:TransformDialog"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/trendline.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatTrendline"/>
+  <contextmenu:menuitem xlink:href=".uno:FormatTrendlineEquation"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertTrendlineEquation"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertTrendlineEquationAndR2"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteTrendlineEquation"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/trendlnequation.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatTrendlineEquation"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertR2Value"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteR2Value"/>
+  <contextmenu:menuitem xlink:href=".uno:TransformDialog"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/wall.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatWall"/>
+  <contextmenu:menuitem xlink:href=".uno:TransformDialog"/><!-- ???? -->
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:InsertTitles"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertRemoveAxes"/>
+  <contextmenu:menuitem xlink:href=".uno:InsertLegend"/>
+  <contextmenu:menuitem xlink:href=".uno:DeleteLegend"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <!--TODO remove unused ".uno:Cut"/-->
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File chart2/uiconfig/contextmenu/yerrorbars.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE contextmenu:contextmenu PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "contextmenu.dtd">
+<contextmenu:contextmenu xmlns:contextmenu="http://openoffice.org/2010/contextmenu" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <contextmenu:menupopup>
+  <contextmenu:menuitem xlink:href=".uno:FormatYErrorBars"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramType"/>
+  <contextmenu:menuitem xlink:href=".uno:DataRanges"/>
+  <contextmenu:menuitem xlink:href=".uno:DiagramData"/>
+  <contextmenu:menuitem xlink:href=".uno:View3D"/>
+  <contextmenu:menuseparator/>
+  <contextmenu:menuitem xlink:href=".uno:Cut"/>
+  <contextmenu:menuitem xlink:href=".uno:Copy"/>
+  <contextmenu:menuitem xlink:href=".uno:Paste"/>
+ </contextmenu:menupopup>
+</contextmenu:contextmenu>

File officecfg/registry/data/org/openoffice/Office/UI/ChartWindowState.xcu

                     <value>true</value>
                 </prop>
             </node>
+            <!-- ContextMenu -->