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