diff options
author | Rüdiger Timm <rt@openoffice.org> | 2008-02-18 14:58:10 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2008-02-18 14:58:10 +0000 |
commit | a644fdc9bd730394480e9a6ed8595f616acb12b8 (patch) | |
tree | fc5b4e3639ac27cb580b6a155d6ae8b2b217f6df /chart2/source/controller/main/ChartController_Tools.cxx | |
parent | b86de05abe2a64906d62f030cb2f6082cf5e6de3 (diff) |
INTEGRATION: CWS chart19 (1.5.8); FILE MERGED
2008/01/15 07:46:45 bm 1.5.8.2: #i44768# allow deleting a trendline with pressing deleting its legend key
2008/01/14 13:46:10 bm 1.5.8.1: #i44768# insert/delete mean value lines via menu commands
Diffstat (limited to 'chart2/source/controller/main/ChartController_Tools.cxx')
-rw-r--r-- | chart2/source/controller/main/ChartController_Tools.cxx | 101 |
1 files changed, 75 insertions, 26 deletions
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 28a1f47024f9..07441caf39d6 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -4,9 +4,9 @@ * * $RCSfile: ChartController_Tools.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: ihi $ $Date: 2007-11-23 11:54:29 $ + * last change: $Author: rt $ $Date: 2008-02-18 15:58:10 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -95,8 +95,56 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; -// namespace -// { +namespace +{ + +bool lcl_deleteDataSeries( + const OUString & rCID, + const Reference< frame::XModel > & xModel, + const Reference< chart2::XUndoManager > & xUndoManager ) +{ + bool bResult = false; + uno::Reference< chart2::XDataSeries > xSeries( ::chart::ObjectIdentifier::getDataSeriesForCID( rCID, xModel )); + uno::Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY ); + if( xSeries.is() && xChartDoc.is()) + { + uno::Reference< chart2::XChartType > xChartType( + ::chart::DataSeriesHelper::getChartTypeOfSeries( xSeries, xChartDoc->getFirstDiagram())); + if( xChartType.is()) + { + ::chart::UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_DATASERIES )))), + xUndoManager, xModel ); + ::chart::DataSeriesHelper::deleteSeries( xSeries, xChartType ); + bResult = true; + aUndoGuard.commitAction(); + } + } + return bResult; +} + +bool lcl_deleteDataCurve( + const OUString & rCID, + const Reference< frame::XModel > & xModel, + const Reference< chart2::XUndoManager > & xUndoManager ) +{ + bool bResult = false; + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + ::chart::ObjectIdentifier::getObjectPropertySet( + ::chart::ObjectIdentifier::getSeriesParticleFromCID( rCID ), xModel ), uno::UNO_QUERY ); + if( xRegCurveCnt.is()) + { + ::chart::UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_CURVE )))), + xUndoManager, xModel ); + ::chart::RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); + bResult = true; + aUndoGuard.commitAction(); + } + return bResult; +} // void lcl_CopyPageContentToPage( // const Reference< drawing::XDrawPage > & xSourcePage, @@ -143,7 +191,7 @@ using ::rtl::OUString; // } // } -// } // anonymous namespace +} // anonymous namespace namespace { @@ -495,7 +543,8 @@ bool ChartController::isObjectDeleteable( const uno::Any& rSelection ) return true; if( (OBJECTTYPE_DATA_SERIES == aObjectType) || (OBJECTTYPE_LEGEND_ENTRY == aObjectType) ) return true; - if( (OBJECTTYPE_DATA_CURVE_EQUATION == aObjectType) || (OBJECTTYPE_DATA_CURVE == aObjectType) ) + if( (OBJECTTYPE_DATA_CURVE_EQUATION == aObjectType) || (OBJECTTYPE_DATA_CURVE == aObjectType) || + (OBJECTTYPE_DATA_AVERAGE_LINE == aObjectType)) return true; if( (OBJECTTYPE_DATA_LABELS == aObjectType) || (OBJECTTYPE_DATA_LABEL == aObjectType) ) return true; @@ -559,28 +608,23 @@ bool ChartController::executeDispatch_Delete() } break; } - case OBJECTTYPE_DATA_SERIES: //fall through intended + + case OBJECTTYPE_DATA_SERIES: + bReturn = lcl_deleteDataSeries( aCID, m_aModel->getModel(), m_xUndoManager ); + break; + case OBJECTTYPE_LEGEND_ENTRY: { - uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( aCID, m_aModel->getModel() )); - if( xSeries.is() ) - { - uno::Reference< chart2::XChartType > xChartType( - DataSeriesHelper::getChartTypeOfSeries( xSeries, xChartDoc->getFirstDiagram())); - if( xChartType.is()) - { - UndoGuard aUndoGuard( - ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_DATASERIES )))), - m_xUndoManager, m_aModel->getModel() ); - DataSeriesHelper::deleteSeries( xSeries, xChartType ); - bReturn = true; - aUndoGuard.commitAction(); - } - } + ObjectType eParentObjectType = ObjectIdentifier::getObjectType( + ObjectIdentifier::getFullParentParticle( aCID )); + if( eParentObjectType == OBJECTTYPE_DATA_SERIES ) + bReturn = lcl_deleteDataSeries( aCID, m_aModel->getModel(), m_xUndoManager ); + else if( eParentObjectType == OBJECTTYPE_DATA_CURVE ) + bReturn = lcl_deleteDataCurve( aCID, m_aModel->getModel(), m_xUndoManager ); break; } - case OBJECTTYPE_DATA_CURVE: + + case OBJECTTYPE_DATA_AVERAGE_LINE: { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( ObjectIdentifier::getObjectPropertySet( @@ -590,14 +634,19 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))), + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), m_xUndoManager, m_aModel->getModel() ); - RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); + RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt ); bReturn = true; aUndoGuard.commitAction(); } break; } + + case OBJECTTYPE_DATA_CURVE: + bReturn = lcl_deleteDataCurve( aCID, m_aModel->getModel(), m_xUndoManager ); + break; + case OBJECTTYPE_DATA_CURVE_EQUATION: { uno::Reference< beans::XPropertySet > xEqProp( |