Kaydet (Commit) 1cd3e203 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Multiple trendline removing and changing type support.

Change-Id: I33a298341e228080920977639cb59986d0b4bd82
üst 4c116a7b
...@@ -867,13 +867,18 @@ WrappedRegressionCurvesProperty::~WrappedRegressionCurvesProperty() ...@@ -867,13 +867,18 @@ WrappedRegressionCurvesProperty::~WrappedRegressionCurvesProperty()
} }
void WrappedRegressionCurvesProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, ::com::sun::star::chart::ChartRegressionCurveType aNewValue ) const void WrappedRegressionCurvesProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, ::com::sun::star::chart::ChartRegressionCurveType aNewValue ) const
{ {
uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY ); uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xSeriesPropertySet, uno::UNO_QUERY );
if( xRegCnt.is() ) uno::Reference< chart2::XRegressionCurve > xRegressionCurve( xSeriesPropertySet, uno::UNO_QUERY );
if( xRegressionCurveContainer.is() && xRegressionCurve.is() )
{ {
RegressionCurveHelper::tRegressionType eNewRegressionType = lcl_getRegressionType( aNewValue ); RegressionCurveHelper::tRegressionType eNewRegressionType = lcl_getRegressionType( aNewValue );
RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCnt );
if( eNewRegressionType != RegressionCurveHelper::REGRESSION_TYPE_NONE ) RegressionCurveHelper::changeRegressionCurveType(
RegressionCurveHelper::addRegressionCurve( eNewRegressionType, xRegCnt, 0, 0 ); eNewRegressionType,
xRegressionCurveContainer,
xRegressionCurve,
uno::Reference< uno::XComponentContext >());
} }
} }
......
...@@ -146,18 +146,12 @@ bool RegressionCurveItemConverter::ApplySpecialItem( ...@@ -146,18 +146,12 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
// for which this converter was created. Not optimal, but // for which this converter was created. Not optimal, but
// currently the only way to handle the type in the // currently the only way to handle the type in the
// regression curve properties dialog // regression curve properties dialog
RegressionCurveHelper::replaceOrAddCurveAndReduceToOne( RegressionCurveHelper::changeRegressionCurveType(
lcl_convertRegressionType( eNewRegress ), m_xCurveContainer, lcl_convertRegressionType( eNewRegress ),
m_xCurveContainer,
xCurve,
uno::Reference< uno::XComponentContext >()); uno::Reference< uno::XComponentContext >());
uno::Reference< beans::XPropertySet > xNewPropSet( bChanged = true;
RegressionCurveHelper::getFirstCurveNotMeanValueLine( m_xCurveContainer ),
uno::UNO_QUERY );
OSL_ASSERT( xNewPropSet.is());
if( xNewPropSet.is())
{
resetPropertySet( xNewPropSet );
bChanged = true;
}
} }
} }
} }
......
...@@ -412,28 +412,38 @@ bool StatisticsItemConverter::ApplySpecialItem( ...@@ -412,28 +412,38 @@ bool StatisticsItemConverter::ApplySpecialItem(
case SCHATTR_REGRESSION_TYPE: case SCHATTR_REGRESSION_TYPE:
{ {
SvxChartRegress eRegress = SvxChartRegress eRegress =
static_cast< const SvxChartRegressItem & >( static_cast< const SvxChartRegressItem& >(
rItemSet.Get( nWhichId )).GetValue(); rItemSet.Get( nWhichId )).GetValue();
uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( uno::Reference< chart2::XRegressionCurve > xRegressionCurve( GetPropertySet(), uno::UNO_QUERY );
GetPropertySet(), uno::UNO_QUERY ); uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( GetPropertySet(), uno::UNO_QUERY );
if( eRegress == CHREGRESS_NONE ) if( eRegress == CHREGRESS_NONE )
{ {
bChanged = RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCnt ); if ( xRegressionCurve.is() )
{
xRegressionCurveContainer->removeRegressionCurve( xRegressionCurve );
bChanged = true;
}
} }
else else
{ {
SvxChartRegress eOldRegress( if ( xRegressionCurve.is() )
static_cast< SvxChartRegress >(
static_cast< sal_Int32 >(
RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( xRegCnt ))));
if( eOldRegress != eRegress )
{ {
RegressionCurveHelper::replaceOrAddCurveAndReduceToOne( SvxChartRegress eOldRegress(
lcl_convertRegressionType( eRegress ), xRegCnt, static_cast< SvxChartRegress >(
uno::Reference< uno::XComponentContext >()); static_cast< sal_Int32 >(
bChanged = true; RegressionCurveHelper::getRegressionType( xRegressionCurve ))));
if( eOldRegress != eRegress )
{
RegressionCurveHelper::changeRegressionCurveType(
lcl_convertRegressionType( eRegress ),
xRegressionCurveContainer,
xRegressionCurve,
uno::Reference< uno::XComponentContext >());
bChanged = true;
}
} }
} }
} }
......
...@@ -386,13 +386,13 @@ void ChartController::executeDispatch_InsertMenu_Trendlines() ...@@ -386,13 +386,13 @@ void ChartController::executeDispatch_InsertMenu_Trendlines()
//prepare and open dialog //prepare and open dialog
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
InsertTrendlineDialog aDlg( m_pChartWindow, aItemSet ); InsertTrendlineDialog aDialog( m_pChartWindow, aItemSet );
aDlg.adjustSize(); aDialog.adjustSize();
if( aDlg.Execute() == RET_OK ) if( aDialog.Execute() == RET_OK )
{ {
SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet();
aDlg.FillItemSet( aOutItemSet ); aDialog.FillItemSet( aOutItemSet );
// lock controllers till end of block // lock controllers till end of block
ControllerLockGuard aCLGuard( getModel() ); ControllerLockGuard aCLGuard( getModel() );
...@@ -443,14 +443,14 @@ void ChartController::executeDispatch_InsertTrendline() ...@@ -443,14 +443,14 @@ void ChartController::executeDispatch_InsertTrendline()
aDialogParameter.init( getModel() ); aDialogParameter.init( getModel() );
ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get()); ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get());
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
SchAttribTabDlg aDlg( m_pChartWindow, &aItemSet, &aDialogParameter, &aViewElementListProvider, SchAttribTabDlg aDialog( m_pChartWindow, &aItemSet, &aDialogParameter, &aViewElementListProvider,
uno::Reference< util::XNumberFormatsSupplier >( getModel(), uno::UNO_QUERY )); uno::Reference< util::XNumberFormatsSupplier >( getModel(), uno::UNO_QUERY ));
// note: when a user pressed "OK" but didn't change any settings in the // note: when a user pressed "OK" but didn't change any settings in the
// dialog, the SfxTabDialog returns "Cancel" // dialog, the SfxTabDialog returns "Cancel"
if( aDlg.Execute() == RET_OK || aDlg.DialogWasClosedWithOK()) if( aDialog.Execute() == RET_OK || aDialog.DialogWasClosedWithOK())
{ {
const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); const SfxItemSet* pOutItemSet = aDialog.GetOutputItemSet();
if( pOutItemSet ) if( pOutItemSet )
{ {
ControllerLockGuard aCLGuard( getModel() ); ControllerLockGuard aCLGuard( getModel() );
......
...@@ -85,6 +85,9 @@ using namespace ::com::sun::star; ...@@ -85,6 +85,9 @@ using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Sequence;
namespace chart
{
namespace namespace
{ {
...@@ -94,25 +97,25 @@ bool lcl_deleteDataSeries( ...@@ -94,25 +97,25 @@ bool lcl_deleteDataSeries(
const Reference< document::XUndoManager > & xUndoManager ) const Reference< document::XUndoManager > & xUndoManager )
{ {
bool bResult = false; bool bResult = false;
uno::Reference< chart2::XDataSeries > xSeries( ::chart::ObjectIdentifier::getDataSeriesForCID( rCID, xModel )); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rCID, xModel ));
uno::Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY ); uno::Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY );
if( xSeries.is() && xChartDoc.is()) if( xSeries.is() && xChartDoc.is())
{ {
uno::Reference< chart2::XChartType > xChartType( uno::Reference< chart2::XChartType > xChartType(
::chart::DataSeriesHelper::getChartTypeOfSeries( xSeries, xChartDoc->getFirstDiagram())); DataSeriesHelper::getChartTypeOfSeries( xSeries, xChartDoc->getFirstDiagram()));
if( xChartType.is()) if( xChartType.is())
{ {
::chart::UndoGuard aUndoGuard( UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription( ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_DATASERIES ))), ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_DATASERIES ))),
xUndoManager ); xUndoManager );
Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( xModel ) ); Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ) );
uno::Reference< chart2::XAxis > xAxis( ::chart::DiagramHelper::getAttachedAxis( xSeries, xDiagram ) ); uno::Reference< chart2::XAxis > xAxis( DiagramHelper::getAttachedAxis( xSeries, xDiagram ) );
::chart::DataSeriesHelper::deleteSeries( xSeries, xChartType ); DataSeriesHelper::deleteSeries( xSeries, xChartType );
::chart::AxisHelper::hideAxisIfNoDataIsAttached( xAxis, xDiagram ); AxisHelper::hideAxisIfNoDataIsAttached( xAxis, xDiagram );
bResult = true; bResult = true;
aUndoGuard.commit(); aUndoGuard.commit();
...@@ -127,28 +130,36 @@ bool lcl_deleteDataCurve( ...@@ -127,28 +130,36 @@ bool lcl_deleteDataCurve(
const Reference< document::XUndoManager > & xUndoManager ) const Reference< document::XUndoManager > & xUndoManager )
{ {
bool bResult = false; bool bResult = false;
uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
::chart::ObjectIdentifier::getObjectPropertySet( uno::Reference< beans::XPropertySet > xProperties(
::chart::ObjectIdentifier::getSeriesParticleFromCID( rCID ), xModel ), uno::UNO_QUERY ); ObjectIdentifier::getObjectPropertySet( rCID, xModel));
if( xRegCurveCnt.is())
uno::Reference< chart2::XRegressionCurve > xRegressionCurve( xProperties, uno::UNO_QUERY );
if( xRegressionCurve.is())
{ {
::chart::UndoGuard aUndoGuard( uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer(
ActionDescriptionProvider::createDescription( ObjectIdentifier::getObjectPropertySet(
ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_CURVE ))), ObjectIdentifier::getFullParentParticle( rCID ), xModel), uno::UNO_QUERY );
xUndoManager );
::chart::RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); if( xRegressionCurveContainer.is())
bResult = true; {
aUndoGuard.commit(); UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))),
xUndoManager );
xRegressionCurveContainer->removeRegressionCurve( xRegressionCurve );
bResult = true;
aUndoGuard.commit();
}
} }
return bResult; return bResult;
} }
} // anonymous namespace } // anonymous namespace
namespace chart
{
SAL_WNODEPRECATED_DECLARATIONS_PUSH SAL_WNODEPRECATED_DECLARATIONS_PUSH
::std::auto_ptr< ReferenceSizeProvider > ChartController::impl_createReferenceSizeProvider() ::std::auto_ptr< ReferenceSizeProvider > ChartController::impl_createReferenceSizeProvider()
{ {
...@@ -657,9 +668,16 @@ bool ChartController::executeDispatch_Delete() ...@@ -657,9 +668,16 @@ bool ChartController::executeDispatch_Delete()
ObjectType eParentObjectType = ObjectIdentifier::getObjectType( ObjectType eParentObjectType = ObjectIdentifier::getObjectType(
ObjectIdentifier::getFullParentParticle( aCID )); ObjectIdentifier::getFullParentParticle( aCID ));
if( eParentObjectType == OBJECTTYPE_DATA_SERIES ) if( eParentObjectType == OBJECTTYPE_DATA_SERIES )
{
bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager ); bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager );
}
else if( eParentObjectType == OBJECTTYPE_DATA_CURVE ) else if( eParentObjectType == OBJECTTYPE_DATA_CURVE )
bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager ); {
sal_Int32 nEndPos = aCID.lastIndexOf(':');
OUString aParentCID = aCID.copy(0, nEndPos);
bReturn = lcl_deleteDataCurve(aParentCID, getModel(), m_xUndoManager );
}
else if( eParentObjectType == OBJECTTYPE_DATA_AVERAGE_LINE ) else if( eParentObjectType == OBJECTTYPE_DATA_AVERAGE_LINE )
{ {
executeDispatch_DeleteMeanValue(); executeDispatch_DeleteMeanValue();
...@@ -684,17 +702,20 @@ bool ChartController::executeDispatch_Delete() ...@@ -684,17 +702,20 @@ bool ChartController::executeDispatch_Delete()
bReturn = true; bReturn = true;
aUndoGuard.commit(); aUndoGuard.commit();
} }
break;
} }
break;
case OBJECTTYPE_DATA_CURVE: case OBJECTTYPE_DATA_CURVE:
{
bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager ); bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager );
break; }
break;
case OBJECTTYPE_DATA_CURVE_EQUATION: case OBJECTTYPE_DATA_CURVE_EQUATION:
{ {
uno::Reference< beans::XPropertySet > xEqProp( uno::Reference< beans::XPropertySet > xEqProp(
ObjectIdentifier::getObjectPropertySet( aCID, getModel())); ObjectIdentifier::getObjectPropertySet( aCID, getModel()));
if( xEqProp.is()) if( xEqProp.is())
{ {
uno::Reference< frame::XModel > xModel( getModel() ); uno::Reference< frame::XModel > xModel( getModel() );
...@@ -711,8 +732,8 @@ bool ChartController::executeDispatch_Delete() ...@@ -711,8 +732,8 @@ bool ChartController::executeDispatch_Delete()
bReturn = true; bReturn = true;
aUndoGuard.commit(); aUndoGuard.commit();
} }
break;
} }
break;
case OBJECTTYPE_DATA_ERRORS_X: case OBJECTTYPE_DATA_ERRORS_X:
case OBJECTTYPE_DATA_ERRORS_Y: case OBJECTTYPE_DATA_ERRORS_Y:
......
...@@ -152,12 +152,14 @@ public: ...@@ -152,12 +152,14 @@ public:
<p>This function ignores mean-value lines.</p> <p>This function ignores mean-value lines.</p>
*/ */
static void replaceOrAddCurveAndReduceToOne( static void changeRegressionCurveType(
tRegressionType eType, tRegressionType eType,
::com::sun::star::uno::Reference< com::sun::star::uno::Reference<
::com::sun::star::chart2::XRegressionCurveContainer > & xRegCnt, com::sun::star::chart2::XRegressionCurveContainer > & xRegressionCurveContainer,
const ::com::sun::star::uno::Reference< com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext > & xContext ); com::sun::star::chart2::XRegressionCurve > & xRegressionCurve,
const com::sun::star::uno::Reference<
com::sun::star::uno::XComponentContext > & xContext );
// ------------------------------------------------------------ // ------------------------------------------------------------
......
...@@ -382,17 +382,17 @@ void RegressionCurveHelper::addRegressionCurve( ...@@ -382,17 +382,17 @@ void RegressionCurveHelper::addRegressionCurve(
if( xEquationProperties.is()) if( xEquationProperties.is())
xCurve->setEquationProperties( xEquationProperties ); xCurve->setEquationProperties( xEquationProperties );
uno::Reference< beans::XPropertySet > xProp( xCurve, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
if( xProp.is()) if( xProperties.is())
{ {
if( xPropertySource.is()) if( xPropertySource.is())
comphelper::copyProperties( xPropertySource, xProp ); comphelper::copyProperties( xPropertySource, xProperties );
else else
{ {
uno::Reference< XPropertySet > xSeriesProp( xRegCnt, uno::UNO_QUERY ); uno::Reference< XPropertySet > xSeriesProp( xRegCnt, uno::UNO_QUERY );
if( xSeriesProp.is()) if( xSeriesProp.is())
{ {
xProp->setPropertyValue( "LineColor", xProperties->setPropertyValue( "LineColor",
xSeriesProp->getPropertyValue( "Color")); xSeriesProp->getPropertyValue( "Color"));
} }
// xProp->setPropertyValue( "LineWidth", uno::makeAny( sal_Int32( 100 ))); // xProp->setPropertyValue( "LineWidth", uno::makeAny( sal_Int32( 100 )));
...@@ -472,26 +472,19 @@ void RegressionCurveHelper::removeEquations( ...@@ -472,26 +472,19 @@ void RegressionCurveHelper::removeEquations(
} }
} }
void RegressionCurveHelper::replaceOrAddCurveAndReduceToOne( void RegressionCurveHelper::changeRegressionCurveType(
tRegressionType eType, tRegressionType eType,
uno::Reference< XRegressionCurveContainer > & xRegCnt, uno::Reference< XRegressionCurveContainer > & xRegressionCurveContainer,
uno::Reference< XRegressionCurve > & xRegressionCurve,
const uno::Reference< XComponentContext > & xContext ) const uno::Reference< XComponentContext > & xContext )
{ {
uno::Reference< chart2::XRegressionCurve > xRegressionCurve( getFirstCurveNotMeanValueLine( xRegCnt )); xRegressionCurveContainer->removeRegressionCurve( xRegressionCurve );
if( ! xRegressionCurve.is()) RegressionCurveHelper::addRegressionCurve(
RegressionCurveHelper::addRegressionCurve( eType, xRegCnt, xContext ); eType,
else xRegressionCurveContainer,
{ xContext,
OUString aServiceName( lcl_getServiceNameForType( eType )); uno::Reference< beans::XPropertySet >( xRegressionCurve, uno::UNO_QUERY ),
if( !aServiceName.isEmpty()) xRegressionCurve->getEquationProperties());
{
RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCnt );
RegressionCurveHelper::addRegressionCurve(
eType, xRegCnt, xContext,
Reference< beans::XPropertySet >( xRegressionCurve, uno::UNO_QUERY ),
xRegressionCurve->getEquationProperties());
}
}
} }
uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getFirstCurveNotMeanValueLine( uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getFirstCurveNotMeanValueLine(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment