[Libreoffice-commits] core.git: Branch 'feature/polynomialregression' - 2 commits - chart2/source
Tomaž Vajngerl
quikee at gmail.com
Sat Jun 29 09:47:13 PDT 2013
chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx | 15 +-
chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx | 16 --
chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx | 36 +++-
chart2/source/controller/main/ChartController_Insert.cxx | 14 -
chart2/source/controller/main/ChartController_Tools.cxx | 75 ++++++----
chart2/source/inc/RegressionCurveHelper.hxx | 12 -
chart2/source/tools/RegressionCurveHelper.cxx | 35 +---
chart2/source/view/charttypes/VSeriesPlotter.cxx | 19 +-
8 files changed, 124 insertions(+), 98 deletions(-)
New commits:
commit 3aa28beb56ca699c51ac9f1d328a60f0eb40eb10
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Sat Jun 29 18:43:16 2013 +0200
Multiple trendline removing and changing type support.
Change-Id: I33a298341e228080920977639cb59986d0b4bd82
diff --git a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx
index cbb208b..216217f 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx
@@ -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 >());
}
}
diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index 011853f..9c4f1bf 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -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;
}
}
}
diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index c4b6896..2a8ebc8e 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -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;
+ }
}
}
}
diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx
index 8741ec9..6461a8a 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -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() );
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 889be43..68bb75d 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -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:
diff --git a/chart2/source/inc/RegressionCurveHelper.hxx b/chart2/source/inc/RegressionCurveHelper.hxx
index 6adb736..5f209dd 100644
--- a/chart2/source/inc/RegressionCurveHelper.hxx
+++ b/chart2/source/inc/RegressionCurveHelper.hxx
@@ -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 );
// ------------------------------------------------------------
diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx
index 5ffc1d5..976d125 100644
--- a/chart2/source/tools/RegressionCurveHelper.cxx
+++ b/chart2/source/tools/RegressionCurveHelper.cxx
@@ -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(
commit ca6edfb135750dd553174134ce1b389d751ceec8
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Sat Jun 29 18:38:32 2013 +0200
VSeriesPlotter cleanup.
Change-Id: Ie9a2fa2a241826581eb799bafa796c54d558d976
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index e8b4fa9..6cb69a5 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -963,10 +963,10 @@ void VSeriesPlotter::createErrorBar_Y( const drawing::Position3D& rUnscaledLogic
}
}
-void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries
- , const uno::Reference< drawing::XShapes >& xTarget
- , const uno::Reference< drawing::XShapes >& xEquationTarget
- , bool bMaySkipPointsInRegressionCalculation )
+void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries,
+ const uno::Reference< drawing::XShapes >& xTarget,
+ const uno::Reference< drawing::XShapes >& xEquationTarget,
+ bool bMaySkipPointsInRegressionCalculation )
{
if(m_nDimension!=2)
return;
@@ -977,6 +977,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries
uno::Sequence< uno::Reference< XRegressionCurve > > aCurveList =
xRegressionContainer->getRegressionCurves();
+
for(sal_Int32 nN=0; nN<aCurveList.getLength(); nN++)
{
uno::Reference< beans::XPropertySet > xProperties( aCurveList[nN], uno::UNO_QUERY );
@@ -1039,6 +1040,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries
fMinX, fMaxX, nRegressionPointCount, xScalingX, xScalingY, bMaySkipPointsInRegressionCalculation ));
nRegressionPointCount = aCalculatedPoints.getLength();
bool bAverageLine = RegressionCurveHelper::isMeanValueLine( aCurveList[nN] );
+
for(sal_Int32 nP=0; nP<nRegressionPointCount; nP++)
{
double fLogicX = aCalculatedPoints[nP].X;
@@ -1049,9 +1051,9 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries
if(!bAverageLine)
m_pPosHelper->doLogicScaling( &fLogicX, &fLogicY, &fLogicZ );
- if( !::rtl::math::isNan(fLogicX) && !::rtl::math::isInf(fLogicX)
- && !::rtl::math::isNan(fLogicY) && !::rtl::math::isInf(fLogicY)
- && !::rtl::math::isNan(fLogicZ) && !::rtl::math::isInf(fLogicZ) )
+ if(!rtl::math::isNan(fLogicX) && !rtl::math::isInf(fLogicX) &&
+ !rtl::math::isNan(fLogicY) && !rtl::math::isInf(fLogicY) &&
+ !rtl::math::isNan(fLogicZ) && !rtl::math::isInf(fLogicZ) )
{
aRegressionPoly.SequenceX[0][nRealPointCount] = fLogicX;
aRegressionPoly.SequenceY[0][nRealPointCount] = fLogicY;
@@ -1070,9 +1072,8 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries
awt::Point aDefaultPos;
if( aRegressionPoly.SequenceX.getLength() && aRegressionPoly.SequenceX[0].getLength() )
{
- uno::Reference< beans::XPropertySet > xCurveModelProp( aCurveList[nN], uno::UNO_QUERY );
VLineProperties aVLineProperties;
- aVLineProperties.initFromPropertySet( xCurveModelProp );
+ aVLineProperties.initFromPropertySet( xProperties );
//create an extra group shape for each curve for selection handling
uno::Reference< drawing::XShapes > xRegressionGroupShapes =
More information about the Libreoffice-commits
mailing list