diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-05-22 20:50:55 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-24 11:57:03 +0200 |
commit | eb6f62496d7f0c8c477dc17bbcc00d0bfa3ae50b (patch) | |
tree | 44809422a7597f1668cc3d487e96ec24537e8a61 /chart2 | |
parent | e3f038db8a61e6c76ff40cd4d0d01f0b16e9378b (diff) |
no need to instantiate these services indirectly
Change-Id: I5c798d2b0ac3895963cbb907e4a25fc0f14a9a2f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134745
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/controller/main/ChartController_Window.cxx | 398 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartFrameloader.cxx | 31 | ||||
-rw-r--r-- | chart2/source/model/main/ChartModel_Persistence.cxx | 6 |
3 files changed, 208 insertions, 227 deletions
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 09ee8b6a28b7..c50749c42a87 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -84,6 +84,7 @@ #include <vcl/ptrstyle.hxx> #include <svtools/acceleratorexecute.hxx> #include <tools/diagnose_ex.h> +#include <toolkit/awt/vclxmenu.hxx> #include <sal/log.hxx> #include <o3tl/string_view.hxx> @@ -1004,8 +1005,7 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() ) impl_notifySelectionChangeListeners(); - css::uno::Reference< css::awt::XPopupMenu > xPopupMenu( m_xCC->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.PopupMenu", m_xCC ), css::uno::UNO_QUERY ); + rtl::Reference< VCLXPopupMenu > xPopupMenu = new VCLXPopupMenu(); Point aPos( rCEvt.GetMousePosPixel() ); if( !rCEvt.IsMouseEvent() ) @@ -1021,243 +1021,235 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) else { // todo: the context menu should be specified by an xml file in uiconfig - if( xPopupMenu.is()) - { - sal_Int16 nUniqueId = 1; - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Cut" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Copy" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Paste" ); - xPopupMenu->insertSeparator( -1 ); + sal_Int16 nUniqueId = 1; + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Cut" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Copy" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Paste" ); + xPopupMenu->insertSeparator( -1 ); - ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); - rtl::Reference< Diagram > xDiagram = getFirstDiagram(); + ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); + rtl::Reference< Diagram > xDiagram = getFirstDiagram(); - OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, aFormatCommand ); + OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, aFormatCommand ); - //some commands for dataseries and points: + //some commands for dataseries and points: - if( eObjectType == OBJECTTYPE_DATA_SERIES || eObjectType == OBJECTTYPE_DATA_POINT ) + if( eObjectType == OBJECTTYPE_DATA_SERIES || eObjectType == OBJECTTYPE_DATA_POINT ) + { + bool bIsPoint = ( eObjectType == OBJECTTYPE_DATA_POINT ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); + rtl::Reference< RegressionCurveModel > xTrendline = RegressionCurveHelper::getFirstCurveNotMeanValueLine( xSeries ); + bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline ); + rtl::Reference< RegressionCurveModel > xMeanValue = RegressionCurveHelper::getMeanValueLine( xSeries ); + bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries ); + bool bHasXErrorBars = StatisticsHelper::hasErrorBars( xSeries, false ); + bool bHasDataLabelsAtSeries = DataSeriesHelper::hasDataLabelsAtSeries( xSeries ); + bool bHasDataLabelsAtPoints = DataSeriesHelper::hasDataLabelsAtPoints( xSeries ); + bool bHasDataLabelAtPoint = false; + sal_Int32 nPointIndex = -1; + if( bIsPoint ) { - bool bIsPoint = ( eObjectType == OBJECTTYPE_DATA_POINT ); - rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); - rtl::Reference< RegressionCurveModel > xTrendline = RegressionCurveHelper::getFirstCurveNotMeanValueLine( xSeries ); - bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline ); - rtl::Reference< RegressionCurveModel > xMeanValue = RegressionCurveHelper::getMeanValueLine( xSeries ); - bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries ); - bool bHasXErrorBars = StatisticsHelper::hasErrorBars( xSeries, false ); - 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; + nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); + bHasDataLabelAtPoint = DataSeriesHelper::hasDataLabelAtPoint( xSeries, nPointIndex ); + } + bool bSelectedPointIsFormatted = false; + bool bHasFormattedDataPointsOtherThanSelected = false; - if( xSeries.is() ) + if( xSeries.is() ) + { + uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; + if( xSeries->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) { - uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - if( xSeries->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) + if( aAttributedDataPointIndexList.hasElements() ) { - if( aAttributedDataPointIndexList.hasElements() ) + if( bIsPoint ) { - if( bIsPoint ) - { - auto aIt = std::find( std::as_const(aAttributedDataPointIndexList).begin(), std::as_const(aAttributedDataPointIndexList).end(), nPointIndex ); - if( aIt != std::as_const(aAttributedDataPointIndexList).end()) - bSelectedPointIsFormatted = true; - else - bHasFormattedDataPointsOtherThanSelected = true; - } + auto aIt = std::find( std::as_const(aAttributedDataPointIndexList).begin(), std::as_const(aAttributedDataPointIndexList).end(), nPointIndex ); + if( aIt != std::as_const(aAttributedDataPointIndexList).end()) + bSelectedPointIsFormatted = true; else bHasFormattedDataPointsOtherThanSelected = true; } + else + bHasFormattedDataPointsOtherThanSelected = true; } } + } - if( bIsPoint ) - { - if( bHasDataLabelAtPoint ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataLabel" ); - if( !bHasDataLabelAtPoint ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertDataLabel" ); - else - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteDataLabel" ); - if( bSelectedPointIsFormatted ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:ResetDataPoint" ); + if( bIsPoint ) + { + if( bHasDataLabelAtPoint ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataLabel" ); + if( !bHasDataLabelAtPoint ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertDataLabel" ); + else + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteDataLabel" ); + if( bSelectedPointIsFormatted ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:ResetDataPoint" ); - xPopupMenu->insertSeparator( -1 ); + xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataSeries" ); - } + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataSeries" ); + } - rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); - if( xChartType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) + rtl::Reference< ChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); + if( xChartType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) + { + try { - try - { - bool bJapaneseStyle = false; - xChartType->getPropertyValue( "Japanese" ) >>= bJapaneseStyle; + bool bJapaneseStyle = false; + xChartType->getPropertyValue( "Japanese" ) >>= bJapaneseStyle; - if( bJapaneseStyle ) - { - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" ); - } - } - catch( const uno::Exception & ) + if( bJapaneseStyle ) { - DBG_UNHANDLED_EXCEPTION("chart2"); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" ); } } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + } - if( bHasDataLabelsAtSeries ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataLabels" ); - if( bHasEquation ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatTrendlineEquation" ); - if( xMeanValue.is() ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMeanValue" ); - if( bHasXErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatXErrorBars" ); - if( bHasYErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatYErrorBars" ); + if( bHasDataLabelsAtSeries ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataLabels" ); + if( bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatTrendlineEquation" ); + if( xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMeanValue" ); + if( bHasXErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatXErrorBars" ); + if( bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatYErrorBars" ); - xPopupMenu->insertSeparator( -1 ); + xPopupMenu->insertSeparator( -1 ); - if( !bHasDataLabelsAtSeries ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertDataLabels" ); - - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendline" ); - - if( !xMeanValue.is() ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMeanValue" ); - if( !bHasXErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertXErrorBars" ); - if( !bHasYErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertYErrorBars" ); - if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteDataLabels" ); - if( bHasEquation ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendlineEquation" ); - if( xMeanValue.is() ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMeanValue" ); - if( bHasXErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteXErrorBars" ); - if( bHasYErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteYErrorBars" ); - - if( bHasFormattedDataPointsOtherThanSelected ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:ResetAllDataPoints" ); + if( !bHasDataLabelsAtSeries ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertDataLabels" ); + + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendline" ); + + if( !xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMeanValue" ); + if( !bHasXErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertXErrorBars" ); + if( !bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertYErrorBars" ); + if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteDataLabels" ); + if( bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendlineEquation" ); + if( xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMeanValue" ); + if( bHasXErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteXErrorBars" ); + if( bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteYErrorBars" ); + + if( bHasFormattedDataPointsOtherThanSelected ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:ResetAllDataPoints" ); - xPopupMenu->insertSeparator( -1 ); + xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId, ".uno:ArrangeRow" ); - uno::Reference< awt::XPopupMenu > xArrangePopupMenu( - m_xCC->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.PopupMenu", m_xCC ), uno::UNO_QUERY ); - if( xArrangePopupMenu.is() ) - { - sal_Int16 nSubId = nUniqueId + 1; - lcl_insertMenuCommand( xArrangePopupMenu, nSubId++, ".uno:Forward" ); - lcl_insertMenuCommand( xArrangePopupMenu, nSubId, ".uno:Backward" ); - xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu ); - nUniqueId = nSubId; - } - ++nUniqueId; - } - else if( eObjectType == OBJECTTYPE_DATA_CURVE ) - { - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendline" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatTrendlineEquation" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendlineEquation" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendlineEquationAndR2" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertR2Value" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendlineEquation" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteR2Value" ); - } - else if( eObjectType == OBJECTTYPE_DATA_CURVE_EQUATION ) - { - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertR2Value" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteR2Value" ); - } + lcl_insertMenuCommand( xPopupMenu, nUniqueId, ".uno:ArrangeRow" ); + rtl::Reference< VCLXPopupMenu > xArrangePopupMenu = new VCLXPopupMenu(); + sal_Int16 nSubId = nUniqueId + 1; + lcl_insertMenuCommand( xArrangePopupMenu, nSubId++, ".uno:Forward" ); + lcl_insertMenuCommand( xArrangePopupMenu, nSubId, ".uno:Backward" ); + xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu ); + nUniqueId = nSubId; + ++nUniqueId; + } + else if( eObjectType == OBJECTTYPE_DATA_CURVE ) + { + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendline" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatTrendlineEquation" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendlineEquation" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendlineEquationAndR2" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertR2Value" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendlineEquation" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteR2Value" ); + } + else if( eObjectType == OBJECTTYPE_DATA_CURVE_EQUATION ) + { + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertR2Value" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteR2Value" ); + } - //some commands for axes: and grids + //some commands for axes: and grids - else if( eObjectType == OBJECTTYPE_AXIS || eObjectType == OBJECTTYPE_GRID || eObjectType == OBJECTTYPE_SUBGRID ) + else if( eObjectType == OBJECTTYPE_AXIS || eObjectType == OBJECTTYPE_GRID || eObjectType == OBJECTTYPE_SUBGRID ) + { + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); + if( xAxis.is() && xDiagram.is() ) { - rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); - 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 = !TitleHelper::getCompleteString( xAxis->getTitleObject() ).isEmpty(); - - if( eObjectType != OBJECTTYPE_AXIS && bIsAxisVisible ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatAxis" ); - if( eObjectType != OBJECTTYPE_GRID && bIsMajorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMajorGrid" ); - if( eObjectType != OBJECTTYPE_SUBGRID && bIsMinorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMinorGrid" ); - - xPopupMenu->insertSeparator( -1 ); - - if( eObjectType != OBJECTTYPE_AXIS && !bIsAxisVisible ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertAxis" ); - if( eObjectType != OBJECTTYPE_GRID && !bIsMajorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMajorGrid" ); - if( eObjectType != OBJECTTYPE_SUBGRID && !bIsMinorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMinorGrid" ); - if( !bHasTitle ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertAxisTitle" ); - - if( bIsAxisVisible ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteAxis" ); - if( bIsMajorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMajorGrid" ); - if( bIsMinorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMinorGrid" ); - } - } - - if( eObjectType == OBJECTTYPE_DATA_STOCK_LOSS ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" ); - else if( eObjectType == OBJECTTYPE_DATA_STOCK_GAIN ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" ); + 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 = !TitleHelper::getCompleteString( xAxis->getTitleObject() ).isEmpty(); + + if( eObjectType != OBJECTTYPE_AXIS && bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatAxis" ); + if( eObjectType != OBJECTTYPE_GRID && bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMajorGrid" ); + if( eObjectType != OBJECTTYPE_SUBGRID && bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMinorGrid" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:TransformDialog" ); + xPopupMenu->insertSeparator( -1 ); - if( eObjectType == OBJECTTYPE_PAGE || eObjectType == OBJECTTYPE_DIAGRAM - || eObjectType == OBJECTTYPE_DIAGRAM_WALL - || eObjectType == OBJECTTYPE_DIAGRAM_FLOOR - || eObjectType == OBJECTTYPE_UNKNOWN ) - { - if( eObjectType != OBJECTTYPE_UNKNOWN ) - xPopupMenu->insertSeparator( -1 ); - bool bHasLegend = LegendHelper::hasLegend( xDiagram ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTitles" ); - if( !bHasLegend ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertLegend" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertRemoveAxes" ); - if( bHasLegend ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteLegend" ); + if( eObjectType != OBJECTTYPE_AXIS && !bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertAxis" ); + if( eObjectType != OBJECTTYPE_GRID && !bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMajorGrid" ); + if( eObjectType != OBJECTTYPE_SUBGRID && !bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMinorGrid" ); + if( !bHasTitle ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertAxisTitle" ); + + if( bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteAxis" ); + if( bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMajorGrid" ); + if( bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMinorGrid" ); } + } - xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DiagramType" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DataRanges" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DiagramData" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:View3D" ); + if( eObjectType == OBJECTTYPE_DATA_STOCK_LOSS ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" ); + else if( eObjectType == OBJECTTYPE_DATA_STOCK_GAIN ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" ); + + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:TransformDialog" ); + + if( eObjectType == OBJECTTYPE_PAGE || eObjectType == OBJECTTYPE_DIAGRAM + || eObjectType == OBJECTTYPE_DIAGRAM_WALL + || eObjectType == OBJECTTYPE_DIAGRAM_FLOOR + || eObjectType == OBJECTTYPE_UNKNOWN ) + { + if( eObjectType != OBJECTTYPE_UNKNOWN ) + xPopupMenu->insertSeparator( -1 ); + bool bHasLegend = LegendHelper::hasLegend( xDiagram ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTitles" ); + if( !bHasLegend ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertLegend" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertRemoveAxes" ); + if( bHasLegend ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteLegend" ); } + + xPopupMenu->insertSeparator( -1 ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DiagramType" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DataRanges" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DiagramData" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:View3D" ); } css::uno::Sequence< css::uno::Any > aArgs{ diff --git a/chart2/source/controller/main/ChartFrameloader.cxx b/chart2/source/controller/main/ChartFrameloader.cxx index 991c6a87e00f..0ba17d338f5f 100644 --- a/chart2/source/controller/main/ChartFrameloader.cxx +++ b/chart2/source/controller/main/ChartFrameloader.cxx @@ -20,6 +20,8 @@ #include "ChartFrameloader.hxx" #include <servicenames.hxx> #include <MediaDescriptorHelper.hxx> +#include <ChartController.hxx> +#include <ChartModel.hxx> #include <unotools/mediadescriptor.hxx> #include <cppuhelper/supportsservice.hxx> #include <com/sun/star/frame/XLoadable.hpp> @@ -93,35 +95,24 @@ sal_Bool SAL_CALL ChartFrameLoader::load( const uno::Sequence< beans::PropertyVa if( ! xModel.is()) { //@todo?? load mechanism to cancel during loading of document - xModel.set( - m_xCC->getServiceManager()->createInstanceWithContext( - CHART_MODEL_SERVICE_IMPLEMENTATION_NAME, m_xCC ) - , uno::UNO_QUERY ); + xModel = new ChartModel(m_xCC); if( impl_checkCancel() ) return false; } //create the controller(+XWindow) - uno::Reference< frame::XController > xController; - uno::Reference< awt::XWindow > xComponentWindow; - { - xController.set( - m_xCC->getServiceManager()->createInstanceWithContext( - CHART_CONTROLLER_SERVICE_IMPLEMENTATION_NAME,m_xCC ) - , uno::UNO_QUERY ); + rtl::Reference< ChartController > xController = new ChartController(m_xCC); - //!!!it is a special characteristic of the example application - //that the controller simultaneously provides the XWindow controller functionality - xComponentWindow = - uno::Reference< awt::XWindow >( xController, uno::UNO_QUERY ); + //!!!it is a special characteristic of the example application + //that the controller simultaneously provides the XWindow controller functionality + uno::Reference< awt::XWindow > xComponentWindow = xController; - if( impl_checkCancel() ) - return false; - } + if( impl_checkCancel() ) + return false; //connect frame, controller and model one to each other: - if(xController.is()&&xModel.is()) + if(xModel.is()) { xModel->connectController(xController); xModel->setCurrentController(xController); @@ -167,7 +158,7 @@ sal_Bool SAL_CALL ChartFrameLoader::load( const uno::Sequence< beans::PropertyVa xLoadable->load( aCompleteMediaDescriptor ); //resize standalone files to get correct size: - if( xComponentWindow.is() && aMDHelper.ISSET_FilterName && aMDHelper.FilterName == "StarChart 5.0" ) + if( aMDHelper.ISSET_FilterName && aMDHelper.FilterName == "StarChart 5.0" ) { awt::Rectangle aRect( xComponentWindow->getPosSize() ); xComponentWindow->setPosSize( aRect.X, aRect.Y, aRect.Width, aRect.Height, 0 ); diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx index b31c510b3e68..a88265374c8b 100644 --- a/chart2/source/model/main/ChartModel_Persistence.cxx +++ b/chart2/source/model/main/ChartModel_Persistence.cxx @@ -31,6 +31,7 @@ #include <DiagramHelper.hxx> #include <BaseCoordinateSystem.hxx> #include <Legend.hxx> +#include <XMLFilter.hxx> #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/container/XNameAccess.hpp> @@ -200,10 +201,7 @@ Reference< document::XFilter > ChartModel::impl_createFilter( if( ! xFilter.is()) { SAL_WARN("chart2", "No FilterName passed in MediaDescriptor" ); - xFilter.set( - m_xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.comp.chart2.XMLFilter", m_xContext ), - uno::UNO_QUERY_THROW ); + xFilter = new XMLFilter(m_xContext); } return xFilter; |