summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorBjörn Milcke <bm@openoffice.org>2003-12-17 15:43:22 +0000
committerBjörn Milcke <bm@openoffice.org>2003-12-17 15:43:22 +0000
commit7eafbb8ad2e1e0f0b967fd912def118c5d660776 (patch)
tree1696b061fffc5965dbe59cd0ffe4b547d65bcae6 /chart2
parent10d693aaef09346d3bdec9158ff477706ac524e3 (diff)
regression curves reimplemented
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/inc/DataPointItemConverter.hxx11
-rw-r--r--chart2/source/controller/inc/StatisticsItemConverter.hxx14
-rw-r--r--chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx10
-rw-r--r--chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx9
-rw-r--r--chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx51
-rw-r--r--chart2/source/controller/main/ChartController_Properties.cxx12
-rw-r--r--chart2/source/inc/RegressionCurveHelper.hxx70
-rw-r--r--chart2/source/tools/LinearRegressionCurveCalculator.cxx5
-rw-r--r--chart2/source/tools/RegressionCalculationHelper.hxx12
-rw-r--r--chart2/source/tools/RegressionCurveHelper.cxx179
-rw-r--r--chart2/source/tools/makefile.mk11
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx11
-rw-r--r--chart2/source/view/main/ChartView.cxx10
-rw-r--r--chart2/source/view/main/VDataSeries.cxx37
-rw-r--r--chart2/source/view/main/VLegend.cxx222
-rw-r--r--chart2/source/view/main/VLegend.hxx13
-rw-r--r--chart2/source/view/main/VLegendSymbolFactory.cxx40
17 files changed, 504 insertions, 213 deletions
diff --git a/chart2/source/controller/inc/DataPointItemConverter.hxx b/chart2/source/controller/inc/DataPointItemConverter.hxx
index 92bb229ee098..6ed183f36f9b 100644
--- a/chart2/source/controller/inc/DataPointItemConverter.hxx
+++ b/chart2/source/controller/inc/DataPointItemConverter.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DataPointItemConverter.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: bm $ $Date: 2003-12-09 16:30:45 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,9 @@
#include "GraphicPropertyItemConverter.hxx"
#include "chartview/NumberFormatterWrapper.hxx"
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
#ifndef _COM_SUN_STAR_AWT_SIZE_HPP_
#include <com/sun/star/awt/Size.hpp>
#endif
@@ -85,7 +88,9 @@ class DataPointItemConverter :
public:
DataPointItemConverter(
const ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > & rPropertySet,
+ ::com::sun::star::frame::XModel > & xChartModel,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropertySet,
SfxItemPool& rItemPool,
SdrModel& rDrawModel,
NumberFormatterWrapper * pNumFormatter,
diff --git a/chart2/source/controller/inc/StatisticsItemConverter.hxx b/chart2/source/controller/inc/StatisticsItemConverter.hxx
index d2342c186e53..fded4b4f6c3f 100644
--- a/chart2/source/controller/inc/StatisticsItemConverter.hxx
+++ b/chart2/source/controller/inc/StatisticsItemConverter.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: StatisticsItemConverter.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: bm $ $Date: 2003-12-10 14:55:57 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,6 +61,10 @@
#ifndef CHART_STATISTICSITEMCONVERTER_HXX
#define CHART_STATISTICSITEMCONVERTER_HXX
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
+
#include "ItemConverter.hxx"
#include "GraphicPropertyItemConverter.hxx"
#include "chartview/NumberFormatterWrapper.hxx"
@@ -80,6 +84,8 @@ class StatisticsItemConverter :
public:
StatisticsItemConverter(
const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > & xChartModel,
+ const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet > & rPropertySet,
SfxItemPool& rItemPool );
virtual ~StatisticsItemConverter();
@@ -92,6 +98,10 @@ protected:
throw( ::com::sun::star::uno::Exception );
virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet )
throw( ::com::sun::star::uno::Exception );
+
+private:
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > m_xModel;
};
} // namespace wrapper
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index c7df6fc18365..dd090ca2c076 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: DataPointItemConverter.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: bm $ $Date: 2003-12-10 18:08:46 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -143,8 +143,8 @@ namespace wrapper
{
DataPointItemConverter::DataPointItemConverter(
- const uno::Reference<
- beans::XPropertySet > & rPropertySet,
+ const uno::Reference< frame::XModel > & xChartModel,
+ const uno::Reference< beans::XPropertySet > & rPropertySet,
SfxItemPool& rItemPool,
SdrModel& rDrawModel,
NumberFormatterWrapper * pNumFormatter,
@@ -159,7 +159,7 @@ DataPointItemConverter::DataPointItemConverter(
m_aConverters.push_back( new CharacterPropertyItemConverter( rPropertySet, rItemPool, pRefSize,
C2U( "ReferenceDiagramSize" )));
if( m_bIncludeStatistics )
- m_aConverters.push_back( new StatisticsItemConverter( rPropertySet, rItemPool ));
+ m_aConverters.push_back( new StatisticsItemConverter( xChartModel, rPropertySet, rItemPool ));
}
DataPointItemConverter::~DataPointItemConverter()
diff --git a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
index 1198657314da..3d794f7c1389 100644
--- a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
+++ b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: MultipleChartConverters.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: bm $ $Date: 2003-12-10 16:51:51 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -179,12 +179,13 @@ AllDataLabelItemConverter::AllDataLabelItemConverter(
uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
if( pRefSize.get())
m_aConverters.push_back( new ::chart::wrapper::DataPointItemConverter(
+ xChartModel,
xObjectProperties, rItemPool, rDrawModel, NULL,
GraphicPropertyItemConverter::FILLED_DATA_POINT,
::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize )) ));
else
m_aConverters.push_back( new ::chart::wrapper::DataPointItemConverter(
- xObjectProperties, rItemPool, rDrawModel, NULL ));
+ xChartModel, xObjectProperties, rItemPool, rDrawModel, NULL ));
}
}
@@ -213,7 +214,7 @@ AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
{
uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
m_aConverters.push_back( new ::chart::wrapper::StatisticsItemConverter(
- xObjectProperties, rItemPool ));
+ xChartModel, xObjectProperties, rItemPool ));
}
}
diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index 8ef61a9b5144..2bd2251067c8 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: StatisticsItemConverter.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: bm $ $Date: 2003-12-16 13:57:00 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,8 @@
#include "RegressionCurveHelper.hxx"
#include "ErrorBar.hxx"
#include "PropertyHelper.hxx"
+#include "ChartModelHelper.hxx"
+#include "ChartTypeHelper.hxx"
#include "GraphicPropertyItemConverter.hxx"
#include "CharacterPropertyItemConverter.hxx"
@@ -118,7 +120,7 @@ bool lcl_HasMeanValueLine( const uno::Reference< chart2::XRegressionCurveContain
uno::Reference< lang::XServiceName > xServName( aCurves[i], uno::UNO_QUERY );
if( xServName.is() &&
xServName->getServiceName().equals(
- C2U( "com.sun.star.comp.chart2.MeanValueRegressionCurve" )))
+ C2U( "com.sun.star.chart2.MeanValueRegressionCurve" )))
{
bResult = true;
break;
@@ -148,7 +150,7 @@ void lcl_RemoveMeanValueLine( uno::Reference< chart2::XRegressionCurveContainer
uno::Reference< lang::XServiceName > xServName( aCurves[i], uno::UNO_QUERY );
if( xServName.is() &&
xServName->getServiceName().equals(
- C2U( "com.sun.star.comp.chart2.MeanValueRegressionCurve" )))
+ C2U( "com.sun.star.chart2.MeanValueRegressionCurve" )))
{
// note: assume that there is only one mean-value curve
xRegCnt->removeRegressionCurve( aCurves[i] );
@@ -164,7 +166,8 @@ void lcl_RemoveMeanValueLine( uno::Reference< chart2::XRegressionCurveContainer
}
void lcl_AddMeanValueLine( uno::Reference< chart2::XRegressionCurveContainer > & xRegCnt,
- const uno::Reference< beans::XPropertySet > & xSeriesProp )
+ const uno::Reference< beans::XPropertySet > & xSeriesProp,
+ const uno::Reference< frame::XModel > & xModel )
{
if( !xRegCnt.is())
return;
@@ -226,28 +229,28 @@ bool lcl_getRegressType( const uno::Reference< chart2::XRegressionCurveContainer
// note: take first regression curve that matches any known
// type (except mean-value line)
if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
- "com.sun.star.comp.chart2.LinearRegressionCurve" )))
+ "com.sun.star.chart2.LinearRegressionCurve" )))
{
rOutRegress = CHREGRESS_LINEAR;
bResult = true;
break;
}
else if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
- "com.sun.star.comp.chart2.LogarithmicRegressionCurve" )))
+ "com.sun.star.chart2.LogarithmicRegressionCurve" )))
{
rOutRegress = CHREGRESS_LOG;
bResult = true;
break;
}
else if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
- "com.sun.star.comp.chart2.ExponentialRegressionCurve" )))
+ "com.sun.star.chart2.ExponentialRegressionCurve" )))
{
rOutRegress = CHREGRESS_EXP;
bResult = true;
break;
}
else if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
- "com.sun.star.comp.chart2.PotentialRegressionCurve" )))
+ "com.sun.star.chart2.PotentialRegressionCurve" )))
{
rOutRegress = CHREGRESS_POWER;
bResult = true;
@@ -268,7 +271,8 @@ bool lcl_getRegressType( const uno::Reference< chart2::XRegressionCurveContainer
uno::Reference< chart2::XRegressionCurve > lcl_createRegressionCurve(
SvxChartRegress eRegress,
const uno::Reference< beans::XPropertySet > & xFormerProp,
- const uno::Reference< beans::XPropertySet > & xSeriesProp )
+ const uno::Reference< beans::XPropertySet > & xSeriesProp,
+ const uno::Reference< frame::XModel > & xModel )
{
uno::Reference< chart2::XRegressionCurve > xResult;
::rtl::OUString aServiceName;
@@ -276,16 +280,16 @@ uno::Reference< chart2::XRegressionCurve > lcl_createRegressionCurve(
switch( eRegress )
{
case CHREGRESS_LINEAR:
- aServiceName = C2U( "com.sun.star.comp.chart2.LinearRegressionCurve" );
+ aServiceName = C2U( "com.sun.star.chart2.LinearRegressionCurve" );
break;
case CHREGRESS_LOG:
- aServiceName = C2U( "com.sun.star.comp.chart2.LogarithmicRegressionCurve" );
+ aServiceName = C2U( "com.sun.star.chart2.LogarithmicRegressionCurve" );
break;
case CHREGRESS_EXP:
- aServiceName = C2U( "com.sun.star.comp.chart2.ExponentialRegressionCurve" );
+ aServiceName = C2U( "com.sun.star.chart2.ExponentialRegressionCurve" );
break;
case CHREGRESS_POWER:
- aServiceName = C2U( "com.sun.star.comp.chart2.PotentialRegressionCurve" );
+ aServiceName = C2U( "com.sun.star.chart2.PotentialRegressionCurve" );
break;
case CHREGRESS_NONE:
@@ -340,13 +344,13 @@ lcl_removeAllKnownRegressionCurves(
uno::Reference< lang::XServiceName > xServName( aCurves[i], uno::UNO_QUERY );
if( xServName.is() &&
( xServName->getServiceName().equals(
- C2U( "com.sun.star.comp.chart2.LinearRegressionCurve" )) ||
+ C2U( "com.sun.star.chart2.LinearRegressionCurve" )) ||
xServName->getServiceName().equals(
- C2U( "com.sun.star.comp.chart2.LogarithmicRegressionCurve" )) ||
+ C2U( "com.sun.star.chart2.LogarithmicRegressionCurve" )) ||
xServName->getServiceName().equals(
- C2U( "com.sun.star.comp.chart2.ExponentialRegressionCurve" )) ||
+ C2U( "com.sun.star.chart2.ExponentialRegressionCurve" )) ||
xServName->getServiceName().equals(
- C2U( "com.sun.star.comp.chart2.PotentialRegressionCurve" ))
+ C2U( "com.sun.star.chart2.PotentialRegressionCurve" ))
))
{
aDeleteIndexes.push_back( i );
@@ -428,10 +432,11 @@ namespace wrapper
{
StatisticsItemConverter::StatisticsItemConverter(
- const uno::Reference<
- beans::XPropertySet > & rPropertySet,
+ const uno::Reference< frame::XModel > & xModel,
+ const uno::Reference< beans::XPropertySet > & rPropertySet,
SfxItemPool& rItemPool ) :
- ItemConverter( rPropertySet, rItemPool )
+ ItemConverter( rPropertySet, rItemPool ),
+ m_xModel( xModel )
{
}
@@ -472,7 +477,7 @@ bool StatisticsItemConverter::ApplySpecialItem(
if( ! bNewHasMeanValueLine )
lcl_RemoveMeanValueLine( xRegCnt );
else
- lcl_AddMeanValueLine( xRegCnt, GetPropertySet() );
+ lcl_AddMeanValueLine( xRegCnt, GetPropertySet(), m_xModel );
bChanged = true;
}
}
@@ -636,7 +641,7 @@ bool StatisticsItemConverter::ApplySpecialItem(
uno::Reference< beans::XPropertySet > xFormerProp(
lcl_removeAllKnownRegressionCurves( xRegCnt ).second );
xRegCnt->addRegressionCurve(
- lcl_createRegressionCurve( eRegress, xFormerProp, GetPropertySet() ));
+ lcl_createRegressionCurve( eRegress, xFormerProp, GetPropertySet(), m_xModel ));
bChanged = true;
}
}
diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx
index 003babc16768..02b558e8bdc1 100644
--- a/chart2/source/controller/main/ChartController_Properties.cxx
+++ b/chart2/source/controller/main/ChartController_Properties.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ChartController_Properties.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: iha $ $Date: 2003-12-15 20:46:10 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -266,6 +266,7 @@ private:
*/
bool bIncludeStatistics = ( eObjectType == OBJECTTYPE_DATA_SERIES );
pItemConverter = new wrapper::DataPointItemConverter(
+ xChartModel,
xObjectProperties, rDrawModel.GetItemPool(), rDrawModel,
pNumberFormatterWrapper, eMapTo, pRefSize,
bIncludeStatistics );
@@ -561,10 +562,11 @@ void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUStrin
uno::Reference< beans::XPropertySet > xObjectProperties =
ObjectIdentifier::getObjectPropertySet( aObjectCID, m_aModel->getModel() );
wrapper::DataPointItemConverter aSymbolItemConverter(
- xObjectProperties
+ m_aModel->getModel()
+ , xObjectProperties
, m_pDrawModelWrapper->getSdrModel().GetItemPool()
- , m_pDrawModelWrapper->getSdrModel(),
- m_pNumberFormatterWrapper
+ , m_pDrawModelWrapper->getSdrModel()
+ , m_pNumberFormatterWrapper
, wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT );
pSymbolShapeProperties = new SfxItemSet( aSymbolItemConverter.CreateEmptyItemSet() );
diff --git a/chart2/source/inc/RegressionCurveHelper.hxx b/chart2/source/inc/RegressionCurveHelper.hxx
index c302844c0f86..a90a85d60432 100644
--- a/chart2/source/inc/RegressionCurveHelper.hxx
+++ b/chart2/source/inc/RegressionCurveHelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: RegressionCurveHelper.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: bm $ $Date: 2003-12-10 16:51:52 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,9 +64,21 @@
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XREGRESSIONCURVE_HPP_
#include <drafts/com/sun/star/chart2/XRegressionCurve.hpp>
#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XREGRESSIONCURVECALCULATOR_HPP_
+#include <drafts/com/sun/star/chart2/XRegressionCurveCalculator.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDATASOURCE_HPP_
+#include <drafts/com/sun/star/chart2/XDataSource.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDATASERIES_HPP_
+#include <drafts/com/sun/star/chart2/XDataSeries.hpp>
+#endif
#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
#include <com/sun/star/uno/XComponentContext.hpp>
#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
namespace chart
{
@@ -74,19 +86,69 @@ namespace chart
class RegressionCurveHelper
{
public:
+ /// returns a model mean-value line
static ::com::sun::star::uno::Reference<
- ::drafts::com::sun::star::chart2::XRegressionCurve >
+ ::drafts::com::sun::star::chart2::XRegressionCurve >
createMeanValueLine(
const ::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext > & xContext );
+ /// returns a model regression curve
static ::com::sun::star::uno::Reference<
- ::drafts::com::sun::star::chart2::XRegressionCurve >
+ ::drafts::com::sun::star::chart2::XRegressionCurve >
createRegressionCurveByServiceName(
const ::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext > & xContext,
::rtl::OUString aServiceName );
+ // ------------------------------------------------------------
+
+ /// returns a calculator object for mean-value lines (used by the view)
+ static ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XRegressionCurveCalculator >
+ createMeanValueLineCalculator();
+
+ /// returns a calculator object for regression curves (used by the view)
+ static ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XRegressionCurveCalculator >
+ createRegressionCurveCalculatorByServiceName(
+ ::rtl::OUString aServiceName );
+
+ /** recalculates the regression parameters according to the data given in
+ the data source.
+
+ A sequence having the role "x-values" will be used as x-values for the
+ calculation if found. Otherwise a sequence (1, 2, 3, ...) of category
+ indexes will be used for the recalculateRegression() method of the
+ regression curve.
+
+ The first sequence having the role "values" will be used as y-values for
+ the recalculateRegression() method of the regression curve.
+
+ @param bUseXValuesIfAvailable
+ If false, the sequence (1, 2, 3, ...) will always be used, even if
+ there is a data-sequence with role "x-values"
+ */
+ static void initializeCurveCalculator(
+ const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XRegressionCurveCalculator > & xOutCurveCalculator,
+ const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XDataSource > & xSource,
+ bool bUseXValuesIfAvailable = true );
+
+ /** Same method as above, but uses the given XModel to determine the
+ parameter bUseXValuesIfAvailable in the above function. It is also
+ necessary that the XDataSource is an XDataSeries, thus this parameter
+ also changed.
+ */
+ static void initializeCurveCalculator(
+ const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XRegressionCurveCalculator > & xOutCurveCalculator,
+ const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XDataSeries > & xSeries,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > & xModel );
+
private:
// not implemented
RegressionCurveHelper();
diff --git a/chart2/source/tools/LinearRegressionCurveCalculator.cxx b/chart2/source/tools/LinearRegressionCurveCalculator.cxx
index b20fdbdb6678..96affb11e4f0 100644
--- a/chart2/source/tools/LinearRegressionCurveCalculator.cxx
+++ b/chart2/source/tools/LinearRegressionCurveCalculator.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: LinearRegressionCurveCalculator.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: bm $ $Date: 2003-12-17 14:06:20 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,7 +60,6 @@
************************************************************************/
#include "LinearRegressionCurveCalculator.hxx"
#include "macros.hxx"
-// #include "algohelper.hxx"
#include "RegressionCalculationHelper.hxx"
#ifndef INCLUDED_RTL_MATH_HXX
diff --git a/chart2/source/tools/RegressionCalculationHelper.hxx b/chart2/source/tools/RegressionCalculationHelper.hxx
index c197a3672ecb..7f07e552f427 100644
--- a/chart2/source/tools/RegressionCalculationHelper.hxx
+++ b/chart2/source/tools/RegressionCalculationHelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: RegressionCalculationHelper.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: bm $ $Date: 2003-12-16 13:55:57 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -66,8 +66,16 @@
#endif
#include <utility>
+#include <functional>
#include <vector>
+#ifndef INCLUDED_RTL_MATH_HXX
+#include <rtl/math.hxx>
+#endif
+
+#define NUMBER_TO_STR(number) (::rtl::OStringToOUString(::rtl::math::doubleToString( \
+ number, rtl_math_StringFormat_G, 4, '.', true ),RTL_TEXTENCODING_ASCII_US ))
+
namespace chart
{
namespace RegressionCalculationHelper
diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx
index c9ea8e8ceffa..4630191befec 100644
--- a/chart2/source/tools/RegressionCurveHelper.cxx
+++ b/chart2/source/tools/RegressionCurveHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: RegressionCurveHelper.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: bm $ $Date: 2003-12-10 16:51:53 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,11 +60,15 @@
************************************************************************/
#include "RegressionCurveHelper.hxx"
#include "ContextHelper.hxx"
-#include "MeanValueRegressionCurve.hxx"
-#include "LinearRegressionCurve.hxx"
-#include "LogarithmicRegressionCurve.hxx"
-#include "ExponentialRegressionCurve.hxx"
-#include "PotentialRegressionCurve.hxx"
+#include "MeanValueRegressionCurveCalculator.hxx"
+#include "LinearRegressionCurveCalculator.hxx"
+#include "LogarithmicRegressionCurveCalculator.hxx"
+#include "ExponentialRegressionCurveCalculator.hxx"
+#include "PotentialRegressionCurveCalculator.hxx"
+#include "CommonConverters.hxx"
+#include "RegressionCurveModel.hxx"
+#include "ChartTypeHelper.hxx"
+#include "ChartModelHelper.hxx"
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTDOCUMENT_HPP_
#include <drafts/com/sun/star/chart2/XChartDocument.hpp>
@@ -76,31 +80,36 @@ namespace chart
//.............................................................................
using namespace ::com::sun::star;
-using namespace ::drafts::com::sun::star;
+using namespace ::drafts::com::sun::star::chart2;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::XComponentContext;
// static
-uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::createMeanValueLine(
- const uno::Reference< uno::XComponentContext > & xContext )
+Reference< XRegressionCurve > RegressionCurveHelper::createMeanValueLine(
+ const Reference< XComponentContext > & xContext )
{
ContextHelper::tContextEntryMapType aContextValues(
ContextHelper::MakeContextEntryMap(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" )), uno::makeAny(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "@mean-value-line" )))));
- return uno::Reference< chart2::XRegressionCurve >(
- new MeanValueRegressionCurve( ContextHelper::createContext( aContextValues, xContext ) ));
+ return Reference< XRegressionCurve >(
+ new RegressionCurveModel( ContextHelper::createContext( aContextValues, xContext ),
+ RegressionCurveModel::CURVE_TYPE_MEAN_VALUE ));
}
// static
-uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::createRegressionCurveByServiceName(
- const uno::Reference< uno::XComponentContext > & xContext,
+Reference< XRegressionCurve > RegressionCurveHelper::createRegressionCurveByServiceName(
+ const Reference< XComponentContext > & xContext,
::rtl::OUString aServiceName )
{
- uno::Reference< chart2::XRegressionCurve > xResult;
+ Reference< XRegressionCurve > xResult;
// todo: use factory methods with service name
if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
- "com.sun.star.comp.chart2.LinearRegressionCurve" )))
+ "com.sun.star.chart2.LinearRegressionCurve" )))
{
ContextHelper::tContextEntryMapType aContextValues(
ContextHelper::MakeContextEntryMap(
@@ -108,10 +117,11 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::createRegressi
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "@linear-regression" )))));
xResult.set(
- new LinearRegressionCurve( ContextHelper::createContext( aContextValues, xContext ) ));
+ new RegressionCurveModel( ContextHelper::createContext( aContextValues, xContext ),
+ RegressionCurveModel::CURVE_TYPE_LINEAR ));
}
else if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
- "com.sun.star.comp.chart2.LogarithmicRegressionCurve" )))
+ "com.sun.star.chart2.LogarithmicRegressionCurve" )))
{
ContextHelper::tContextEntryMapType aContextValues(
ContextHelper::MakeContextEntryMap(
@@ -119,10 +129,11 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::createRegressi
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "@logarithmic-regression" )))));
xResult.set(
- new LogarithmicRegressionCurve( ContextHelper::createContext( aContextValues, xContext ) ));
+ new RegressionCurveModel( ContextHelper::createContext( aContextValues, xContext ),
+ RegressionCurveModel::CURVE_TYPE_LOGARITHM ));
}
else if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
- "com.sun.star.comp.chart2.ExponentialRegressionCurve" )))
+ "com.sun.star.chart2.ExponentialRegressionCurve" )))
{
ContextHelper::tContextEntryMapType aContextValues(
ContextHelper::MakeContextEntryMap(
@@ -130,10 +141,11 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::createRegressi
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "@exponential-regression" )))));
xResult.set(
- new ExponentialRegressionCurve( ContextHelper::createContext( aContextValues, xContext ) ));
+ new RegressionCurveModel( ContextHelper::createContext( aContextValues, xContext ),
+ RegressionCurveModel::CURVE_TYPE_EXPONENTIAL ));
}
else if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
- "com.sun.star.comp.chart2.PotentialRegressionCurve" )))
+ "com.sun.star.chart2.PotentialRegressionCurve" )))
{
ContextHelper::tContextEntryMapType aContextValues(
ContextHelper::MakeContextEntryMap(
@@ -141,13 +153,132 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::createRegressi
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "@potential-regression" )))));
xResult.set(
- new PotentialRegressionCurve( ContextHelper::createContext( aContextValues, xContext ) ));
+ new RegressionCurveModel( ContextHelper::createContext( aContextValues, xContext ),
+ RegressionCurveModel::CURVE_TYPE_POWER ));
+ }
+
+ return xResult;
+}
+
+// ------------------------------------------------------------
+
+// static
+Reference< XRegressionCurveCalculator > RegressionCurveHelper::createMeanValueLineCalculator()
+{
+ return Reference< XRegressionCurveCalculator >( new MeanValueRegressionCurveCalculator());
+}
+
+// static
+Reference< XRegressionCurveCalculator > RegressionCurveHelper::createRegressionCurveCalculatorByServiceName(
+ ::rtl::OUString aServiceName )
+{
+ Reference< XRegressionCurveCalculator > xResult;
+
+ // todo: use factory methods with service name
+ if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ "com.sun.star.chart2.MeanValueRegressionCurve" )))
+ {
+ xResult.set( new MeanValueRegressionCurveCalculator());
+ }
+ if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ "com.sun.star.chart2.LinearRegressionCurve" )))
+ {
+ xResult.set( new LinearRegressionCurveCalculator());
+ }
+ else if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ "com.sun.star.chart2.LogarithmicRegressionCurve" )))
+ {
+ xResult.set( new LogarithmicRegressionCurveCalculator());
+ }
+ else if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ "com.sun.star.chart2.ExponentialRegressionCurve" )))
+ {
+ xResult.set( new ExponentialRegressionCurveCalculator());
+ }
+ else if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ "com.sun.star.chart2.PotentialRegressionCurve" )))
+ {
+ xResult.set( new PotentialRegressionCurveCalculator());
}
return xResult;
}
+// static
+void RegressionCurveHelper::initializeCurveCalculator(
+ const Reference< XRegressionCurveCalculator > & xOutCurveCalculator,
+ const Reference< XDataSource > & xSource,
+ bool bUseXValuesIfAvailable /* = true */ )
+{
+ if( ! (xOutCurveCalculator.is() &&
+ xSource.is() ))
+ return;
+
+ Sequence< double > aXValues, aYValues;
+ bool bXValuesFound = false, bYValuesFound = false;
+
+ Sequence< Reference< XDataSequence > > aDataSeqs( xSource->getDataSequences());
+ for( sal_Int32 i=0;
+ ! (bXValuesFound && bYValuesFound) && i<aDataSeqs.getLength();
+ ++i )
+ {
+ try
+ {
+ Reference< beans::XPropertySet > xProp( aDataSeqs[i], uno::UNO_QUERY_THROW );
+ ::rtl::OUString aRole;
+ if( xProp->getPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Role" ))) >>= aRole )
+ {
+ if( bUseXValuesIfAvailable &&
+ ! bXValuesFound &&
+ aRole.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "x-values" )))
+ {
+ aXValues = DataSequenceToDoubleSequence( aDataSeqs[i] );
+ bXValuesFound = true;
+ }
+ else if( ! bYValuesFound &&
+ aRole.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "values" )))
+ {
+ aYValues = DataSequenceToDoubleSequence( aDataSeqs[i] );
+ bYValuesFound = true;
+ }
+ }
+ }
+ catch( uno::Exception )
+ {
+ }
+ }
+
+ if( ! bXValuesFound &&
+ bYValuesFound )
+ {
+ // initialize with 1, 2, ...
+ aXValues.realloc( aYValues.getLength());
+ for( i=0; i<aXValues.getLength(); )
+ aXValues[i] = ++i;
+ bXValuesFound = true;
+ }
+
+ if( bXValuesFound && bYValuesFound &&
+ aXValues.getLength() > 0 &&
+ aYValues.getLength() > 0 )
+ xOutCurveCalculator->recalculateRegression( aXValues, aYValues );
+}
+
+// static
+void RegressionCurveHelper::initializeCurveCalculator(
+ const Reference< XRegressionCurveCalculator > & xOutCurveCalculator,
+ const Reference< XDataSeries > & xSeries,
+ const Reference< frame::XModel > & xModel )
+{
+ AxisType eAxisType = ChartTypeHelper::getAxisType(
+ ChartModelHelper::getChartTypeOfSeries( xModel, xSeries ), 0 ); // x-axis
+
+ initializeCurveCalculator( xOutCurveCalculator,
+ uno::Reference< XDataSource >( xSeries, uno::UNO_QUERY ),
+ (eAxisType == AxisType_REALNUMBER) );
+}
+
//.............................................................................
} //namespace chart
//.............................................................................
-
diff --git a/chart2/source/tools/makefile.mk b/chart2/source/tools/makefile.mk
index f70887b91820..c12fa4c2a225 100644
--- a/chart2/source/tools/makefile.mk
+++ b/chart2/source/tools/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.13 $
+# $Revision: 1.14 $
#
-# last change: $Author: bm $ $Date: 2003-12-12 17:02:43 $
+# last change: $Author: bm $ $Date: 2003-12-17 16:43:15 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -91,16 +91,17 @@ SLOFILES= \
$(SLO)$/ExponentialRegressionCurve.obj \
$(SLO)$/ImplOPropertySet.obj \
$(SLO)$/LayoutHelper.obj \
- $(SLO)$/LinearRegressionCurve.obj \
+ $(SLO)$/LinearRegressionCurveCalculator.obj \
$(SLO)$/LogarithmicRegressionCurve.obj \
- $(SLO)$/MeanValueRegressionCurve.obj \
+ $(SLO)$/MeanValueRegressionCurveCalculator.obj \
$(SLO)$/OChartElementContainerHelper.obj \
$(SLO)$/OEnumeration.obj \
$(SLO)$/OIndexContainer.obj \
$(SLO)$/OPropertySet.obj \
$(SLO)$/OStyle.obj \
- $(SLO)$/PotentialRegressionCurve.obj \
+ $(SLO)$/PotentialRegressionCurveCalculator.obj \
$(SLO)$/RegressionCurveHelper.obj \
+ $(SLO)$/RegressionCurveModel.obj \
$(SLO)$/Rotation.obj \
$(SLO)$/RelativeSizeHelper.obj \
$(SLO)$/Scaling.obj \
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 6598af37b12e..b0fd5d0bfa17 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -678,8 +678,11 @@ void VSeriesPlotter::createRegressionCurvesShapes( const VDataSeries& rVDataSeri
xRegressionContainer->getRegressionCurves();
for(sal_Int32 nN=0; nN<aCurveList.getLength(); nN++)
{
- uno::Reference< XRegressionCurve > xRegressionCurve( aCurveList[nN] );
- xRegressionCurve->recalculateRegression( rVDataSeries.getAllX(), rVDataSeries.getAllY() );
+ uno::Reference< XRegressionCurveCalculator > xRegressionCurveCalculator(
+ aCurveList[nN]->getCalculator() );
+ if( ! xRegressionCurveCalculator.is())
+ continue;
+ xRegressionCurveCalculator->recalculateRegression( rVDataSeries.getAllX(), rVDataSeries.getAllY() );
sal_Int32 nRegressionPointCount = 50;//@todo find a more optimal solution if more complicated curve types are introduced
drawing::PolyPolygonShape3D aRegressionPoly;
@@ -693,7 +696,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( const VDataSeries& rVDataSeri
for(sal_Int32 nP=0; nP<nRegressionPointCount; nP++)
{
double fLogicX = fMinX + nP*(fMaxX-fMinX)/double(nRegressionPointCount-1);
- double fLogicY = xRegressionCurve->getCurveValue( fLogicX );
+ double fLogicY = xRegressionCurveCalculator->getCurveValue( fLogicX );
double fLogicZ = 0.0;//dummy
m_pPosHelper->doLogicScaling( &fLogicX, &fLogicY, &fLogicZ );
@@ -723,7 +726,7 @@ void VSeriesPlotter::createRegressionCurvesShapes( const VDataSeries& rVDataSeri
if( !aRegressionPoly.SequenceX.getLength() || !aRegressionPoly.SequenceX[0].getLength() )
continue;
- uno::Reference< beans::XPropertySet > xCurveModelProp( xRegressionCurve, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xCurveModelProp( aCurveList[nN], uno::UNO_QUERY );
VLineProperties aVLineProperties;
aVLineProperties.initFromPropertySet( xCurveModelProp );
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 7b47d0da2696..2357d79cd076 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ChartView.cxx,v $
*
- * $Revision: 1.27 $
+ * $Revision: 1.28 $
*
- * last change: $Author: iha $ $Date: 2003-12-12 20:43:35 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:18 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -711,12 +711,12 @@ bool createLegend( const uno::Reference< XLegend > & xLegend
, const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory
, awt::Rectangle & rOutSpaceLeft
, const awt::Size & rPageSize
- )
+ , const uno::Reference< frame::XModel > & xModel )
{
if( VLegend::isVisible( xLegend ))
{
VLegend aVLegend( xLegend );
- aVLegend.init( xPageShapes, xShapeFactory );
+ aVLegend.init( xPageShapes, xShapeFactory, xModel );
aVLegend.createShapes( awt::Size( rOutSpaceLeft.Width, rOutSpaceLeft.Height ),
rPageSize );
aVLegend.changePosition( rOutSpaceLeft, rPageSize );
@@ -818,7 +818,7 @@ bool ChartViewImpl::create( const awt::Size& rPageSize )
//------------ create legend
createLegend( LegendHelper::getLegend( m_xChartModel ), xPageShapes, m_xShapeFactory
- , aRemainingSpace, rPageSize );
+ , aRemainingSpace, rPageSize, m_xChartModel );
if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
return true;
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index a16911dc241b..0effc6c55e9b 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VDataSeries.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: iha $ $Date: 2003-12-17 10:44:12 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,6 +61,7 @@
#include "VDataSeries.hxx"
#include "chartview/ObjectIdentifier.hxx"
#include "macros.hxx"
+#include "CommonConverters.hxx"
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_SYMBOL_HPP_
#include <drafts/com/sun/star/chart2/Symbol.hpp>
@@ -105,34 +106,6 @@ namespace chart
using namespace ::com::sun::star;
using namespace ::drafts::com::sun::star::chart2;
-void initDoubleValues( uno::Sequence< double >& rDoubleValues,
- const uno::Reference< XDataSequence >& xDataSequence )
-{
- OSL_ASSERT( xDataSequence.is());
- if(!xDataSequence.is())
- return;
-
- uno::Reference< XNumericalDataSequence > xNumericalDataSequence
- = uno::Reference< XNumericalDataSequence >( xDataSequence, uno::UNO_QUERY );
- if( xNumericalDataSequence.is() )
- {
- rDoubleValues = xNumericalDataSequence->getNumericalData();
- }
- else
- {
- uno::Sequence< uno::Any > aValues = xDataSequence->getData();
- rDoubleValues.realloc(aValues.getLength());
- for(sal_Int32 nN=aValues.getLength();nN--;)
- {
- if( !(aValues[nN] >>= rDoubleValues[nN]) )
- {
- ::rtl::math::setNan( &rDoubleValues[nN] );
- }
- }
- }
-}
-
-
VDataSeries::VDataSeries()
{
DBG_ERROR("not implemented");
@@ -182,12 +155,12 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries )
if( aRole.equals(C2U("x-values")) )
{
m_xData_XValues = xDataSequence;
- initDoubleValues( m_XValues_Double, m_xData_XValues );
+ m_XValues_Double = DataSequenceToDoubleSequence( m_xData_XValues );
}
else if( aRole.equals(C2U("values")) )
{
m_xData_YValues = xDataSequence;
- initDoubleValues( m_YValues_Double, m_xData_YValues );
+ m_YValues_Double = DataSequenceToDoubleSequence( m_xData_YValues );
m_nPointCount = xDataSequence->getData().getLength(); //@todo determination of m_nPointCount may needs to be improved (e.g. max of x,y,z or something)
}
//@todo assign the other roles (+ error for unknown?)
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index ffb211fbf9a2..16bf113ce0cc 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VLegend.cxx,v $
*
- * $Revision: 1.30 $
+ * $Revision: 1.31 $
*
- * last change: $Author: iha $ $Date: 2003-12-12 20:10:00 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,6 +67,7 @@
#include "LayoutHelper.hxx"
#include "ShapeFactory.hxx"
#include "RelativeSizeHelper.hxx"
+#include "RegressionCurveHelper.hxx"
#ifndef _COM_SUN_STAR_TEXT_XTEXTRANGE_HPP_
#include <com/sun/star/text/XTextRange.hpp>
@@ -104,6 +105,9 @@
#ifndef _DRAFTS_COM_SUN_STAR_LAYOUT_RELATIVEPOSITION_HPP_
#include <drafts/com/sun/star/layout/RelativePosition.hpp>
#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XREGRESSIONCURVECONTAINER_HPP_
+#include <drafts/com/sun/star/chart2/XRegressionCurveContainer.hpp>
+#endif
// header for class Matrix3D
#ifndef _B2D_MATRIX3D_HXX
@@ -131,7 +135,7 @@ namespace
struct LegendEntry
{
- uno::Reference< drawing::XShapes > xGroupShapes;
+ uno::Reference< drawing::XShapes > xGroupShapes;
uno::Reference< drawing::XShape > xTextShape;
uno::Reference< beans::XPropertySet > xSymbolProperties;
uno::Reference< chart2::XChartType > xChartType;
@@ -271,18 +275,20 @@ uno::Reference< drawing::XShape >
{
uno::Reference< drawing::XShape > xResult;
+ xResult.set( xFact->createInstance(
+ C2U( "com.sun.star.drawing.GroupShape" )), uno::UNO_QUERY );
+ xShapeContainer->add( xResult );
+ uno::Reference< drawing::XShapes > xGroup( xResult, uno::UNO_QUERY );
+ if( ! xGroup.is())
+ return uno::Reference< drawing::XShape >();
+
+ xShapeContainer->add( xResult );
+
if( xChartType.is())
{
::rtl::OUString aChartType( xChartType->getChartType());
-
- xResult.set( xFact->createInstance(
- C2U( "com.sun.star.drawing.GroupShape" )), uno::UNO_QUERY );
- xShapeContainer->add( xResult );
- uno::Reference< drawing::XShapes > xGroup( xResult, uno::UNO_QUERY );
- if( ! xGroup.is())
- return uno::Reference< drawing::XShape >();
-
- xShapeContainer->add( xResult );
+ VLegendSymbolFactory::tPropertyType ePropType =
+ VLegendSymbolFactory::PROP_TYPE_FILLED_SERIES;
chart2::LegendSymbolStyle eSymbolStyle = chart2::LegendSymbolStyle_BOX;
@@ -299,6 +305,7 @@ uno::Reference< drawing::XShape >
aChartType.equals( C2U( "com.sun.star.chart2.ScatterChart" )))
{
eSymbolStyle = chart2::LegendSymbolStyle_LINE;
+ ePropType = VLegendSymbolFactory::PROP_TYPE_LINE_SERIES;
try
{
// use a box for 3d-line charts
@@ -320,18 +327,90 @@ uno::Reference< drawing::XShape >
else if( aChartType.equals( C2U( "com.sun.star.chart2.NetChart" )))
{
eSymbolStyle = chart2::LegendSymbolStyle_DIAGONAL_LINE;
+ ePropType = VLegendSymbolFactory::PROP_TYPE_LINE_SERIES;
}
- ::chart::VLegendSymbolFactory::createSymbol( xGroup, eSymbolStyle, xFact, xSeriesProp );
+ ::chart::VLegendSymbolFactory::createSymbol(
+ xGroup, eSymbolStyle, xFact, xSeriesProp, ePropType );
}
else
{
- OSL_ENSURE( false, "No ChartTypeGroup!" );
+ // no chart-type group => assume regression line
+ ::chart::VLegendSymbolFactory::createSymbol(
+ xGroup, chart2::LegendSymbolStyle_DIAGONAL_LINE, xFact, xSeriesProp,
+ VLegendSymbolFactory::PROP_TYPE_LINE );
}
return xResult;
}
+typedef ::std::pair< uno::Reference< drawing::XShape >, uno::Reference< drawing::XShapes > >
+ tShapeWithGroup;
+
+tShapeWithGroup lcl_getLegendEntry(
+ const uno::Reference< lang::XMultiServiceFactory > & xShapeFactory,
+ const uno::Reference< drawing::XShapes > & xTarget,
+ const ::rtl::OUString & rText,
+ const tPropertyValues & rProperties,
+ awt::Size & rOutMinExtentSoFar,
+ awt::Size & rOutMaxExtentSoFar,
+ tEntryGroup & rOutEntryContainer,
+ const ::rtl::OUString & rCID )
+{
+ uno::Reference< drawing::XShape > xEntry;
+ uno::Reference< drawing::XShapes > xGroupShapes;
+ try
+ {
+ // create label shape
+ uno::Reference< drawing::XShape > xGroupShapeForSingleEntry(
+ xShapeFactory->createInstance(
+ C2U( "com.sun.star.drawing.GroupShape" )), uno::UNO_QUERY_THROW );
+ xEntry.set( xShapeFactory->createInstance(
+ C2U( "com.sun.star.drawing.TextShape" )), uno::UNO_QUERY_THROW );
+
+ xTarget->add( xGroupShapeForSingleEntry );
+
+ xGroupShapes.set( xGroupShapeForSingleEntry, uno::UNO_QUERY_THROW );
+ xGroupShapes->add( xEntry );
+
+ // set label text
+ uno::Reference< text::XTextRange > xRange( xEntry, uno::UNO_QUERY );
+ if( xRange.is())
+ xRange->setString( rText );
+
+ // set character properties
+ ::chart::PropertyMapper::setMultiProperties(
+ rProperties.first, rProperties.second,
+ uno::Reference< beans::XPropertySet >( xEntry,uno::UNO_QUERY ) );
+
+ // adapt min-/max-extent
+ awt::Size aEntrySize( xEntry->getSize() );
+ rOutMaxExtentSoFar.Width = ::std::max( rOutMaxExtentSoFar.Width, aEntrySize.Width );
+ rOutMaxExtentSoFar.Height = ::std::max( rOutMaxExtentSoFar.Height, aEntrySize.Height );
+ if( aEntrySize.Height > 0 )
+ {
+ // setting initial value (otherwise (0,0) is always the minimum)
+ if( rOutMinExtentSoFar.Height == 0 )
+ rOutMinExtentSoFar = aEntrySize;
+ else
+ {
+ rOutMinExtentSoFar.Width = ::std::min( rOutMinExtentSoFar.Width, aEntrySize.Width );
+ rOutMinExtentSoFar.Height = ::std::min( rOutMinExtentSoFar.Height, aEntrySize.Height );
+ }
+ }
+
+ // set identifier for selection handling
+ uno::Reference< beans::XPropertySet > xEntryProps( xGroupShapeForSingleEntry,uno::UNO_QUERY );
+ xEntryProps->setPropertyValue( C2U("Name"), uno::makeAny( rCID ));
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+
+ return ::std::make_pair( xEntry, xGroupShapes );
+}
+
/** Note: rOutMinExtentSoFar is the smallest non-zero size
*/
void lcl_getLegendEntries(
@@ -343,7 +422,8 @@ void lcl_getLegendEntries(
const tPropertyValues & rProperties,
awt::Size & rOutMinExtentSoFar,
awt::Size & rOutMaxExtentSoFar,
- const rtl::OUString& rLegendIdentifier )
+ const rtl::OUString& rLegendIdentifier,
+ uno::Reference< frame::XModel > & xModel )
{
uno::Sequence< uno::Reference< chart2::XDataSeriesTreeNode > > aChildren(
xParent->getChildren());
@@ -355,26 +435,13 @@ void lcl_getLegendEntries(
{
// recurse !
lcl_getLegendEntries( xNewParent, rOutEntryContainer, xTarget, xShapeFactory,
- xChartType, rProperties, rOutMinExtentSoFar, rOutMaxExtentSoFar, rLegendIdentifier );
+ xChartType, rProperties, rOutMinExtentSoFar, rOutMaxExtentSoFar,
+ rLegendIdentifier, xModel );
}
else
{
try
{
- // create label shape
- uno::Reference< drawing::XShape > xGroupShapeForSingleEntry(
- xShapeFactory->createInstance(
- C2U( "com.sun.star.drawing.GroupShape" )), uno::UNO_QUERY );
- uno::Reference< drawing::XShape > xEntry(
- xShapeFactory->createInstance(
- C2U( "com.sun.star.drawing.TextShape" )), uno::UNO_QUERY );
- if( !xEntry.is())
- continue;
-
- xTarget->add( xGroupShapeForSingleEntry );
-
- uno::Reference< drawing::XShapes > xGroupShapes( xGroupShapeForSingleEntry, uno::UNO_QUERY );
- xGroupShapes->add( xEntry );
// get label text via data source
::rtl::OUString aName;
uno::Reference< chart2::XDataSource > xSeriesSource(
@@ -382,53 +449,57 @@ void lcl_getLegendEntries(
if( xSeriesSource.is())
aName = lcl_getLabelForSeries( xSeriesSource );
- // set label text
- uno::Reference< text::XTextRange > xRange( xEntry, uno::UNO_QUERY );
- if( xRange.is())
- xRange->setString( aName );
-
- // set character properties
- ::chart::PropertyMapper::setMultiProperties(
- rProperties.first, rProperties.second,
- uno::Reference< beans::XPropertySet >( xEntry,uno::UNO_QUERY ) );
-
- // adapt min-/max-extent
- awt::Size aEntrySize( xEntry->getSize() );
- rOutMaxExtentSoFar.Width = ::std::max( rOutMaxExtentSoFar.Width, aEntrySize.Width );
- rOutMaxExtentSoFar.Height = ::std::max( rOutMaxExtentSoFar.Height, aEntrySize.Height );
- if( aEntrySize.Height > 0 )
- {
- // setting initial value (otherwise (0,0) is always the minimum)
- if( rOutMinExtentSoFar.Height == 0 )
- rOutMinExtentSoFar = aEntrySize;
- else
- {
- rOutMinExtentSoFar.Width = ::std::min( rOutMinExtentSoFar.Width, aEntrySize.Width );
- rOutMinExtentSoFar.Height = ::std::min( rOutMinExtentSoFar.Height, aEntrySize.Height );
- }
- }
+ // identifier for selection handling
+ uno::Reference< beans::XPropertySet > xSeriesProp( xSeriesSource, uno::UNO_QUERY );
+ rtl::OUString aSeriesIdentifier;
+ xSeriesProp->getPropertyValue( C2U( "Identifier" ) ) >>= aSeriesIdentifier;
+
+ rtl::OUString aCID = chart::ObjectIdentifier::createClassifiedIdentifier(
+ chart::OBJECTTYPE_LEGEND_ENTRY, aSeriesIdentifier
+ , chart::ObjectIdentifier::createParticle( chart::OBJECTTYPE_LEGEND, rLegendIdentifier ) );
+
+ tShapeWithGroup aResult(
+ lcl_getLegendEntry( xShapeFactory, xTarget, aName, rProperties,
+ rOutMinExtentSoFar, rOutMaxExtentSoFar,
+ rOutEntryContainer, aCID ));
// add entry to list
- uno::Reference< beans::XPropertySet > xSeriesProp( xSeriesSource, uno::UNO_QUERY );
rOutEntryContainer.push_back(
- tEntryGroup::value_type( xGroupShapes, xEntry, xSeriesProp, xChartType ));
+ tEntryGroup::value_type( aResult.second, aResult.first, xSeriesProp, xChartType ));
- //set identifier for selection handling
- try
- {
- rtl::OUString aSeriesIdentifier;
- uno::Any aAIdentifier = xSeriesProp->getPropertyValue( C2U( "Identifier" ) );
- aAIdentifier >>= aSeriesIdentifier;
-
- rtl::OUString aCID = chart::ObjectIdentifier::createClassifiedIdentifier(
- chart::OBJECTTYPE_LEGEND_ENTRY, aSeriesIdentifier
- , chart::ObjectIdentifier::createParticle( chart::OBJECTTYPE_LEGEND, rLegendIdentifier ) );
- uno::Reference< beans::XPropertySet > xEntryProps( xGroupShapeForSingleEntry,uno::UNO_QUERY );
- xEntryProps->setPropertyValue( C2U("Name"), uno::makeAny( aCID ));
- }
- catch( uno::Exception & ex )
+ uno::Reference< chart2::XRegressionCurveContainer > xRegrCont(
+ aChildren[ nI ], uno::UNO_QUERY );
+ if( xRegrCont.is())
{
- ASSERT_EXCEPTION( ex );
+ uno::Sequence< uno::Reference< chart2::XRegressionCurve > > aCurves(
+ xRegrCont->getRegressionCurves());
+ for( sal_Int32 nJ = 0; nJ < aCurves.getLength(); ++ nJ )
+ {
+ if( aCurves[ nJ ].is())
+ {
+ uno::Reference< chart2::XRegressionCurveCalculator >xCalc(
+ aCurves[ nJ ]->getCalculator());
+ if( xCalc.is())
+ {
+ RegressionCurveHelper::initializeCurveCalculator(
+ xCalc,
+ uno::Reference< chart2::XDataSeries >( aChildren[ nI ], uno::UNO_QUERY ),
+ xModel );
+
+ ::rtl::OUString aText( xCalc->getRepresentation());
+ aResult =
+ lcl_getLegendEntry( xShapeFactory, xTarget, aText, rProperties,
+ rOutMinExtentSoFar, rOutMaxExtentSoFar,
+ rOutEntryContainer, aCID );
+ // add entry to list
+ rOutEntryContainer.push_back(
+ tEntryGroup::value_type( aResult.second, aResult.first,
+ uno::Reference< beans::XPropertySet >(
+ aCurves[ nJ ], uno::UNO_QUERY ),
+ uno::Reference< chart2::XChartType >() ));
+ }
+ }
+ }
}
}
catch( uno::Exception & ex )
@@ -694,10 +765,12 @@ VLegend::VLegend(
void SAL_CALL VLegend::init(
const uno::Reference< drawing::XShapes >& xTargetPage,
- const uno::Reference< lang::XMultiServiceFactory >& xFactory )
+ const uno::Reference< lang::XMultiServiceFactory >& xFactory,
+ const uno::Reference< frame::XModel >& xModel )
{
m_xTarget = xTargetPage;
m_xShapeFactory = xFactory;
+ m_xModel = xModel;
}
// ----------------------------------------
@@ -814,7 +887,8 @@ void VLegend::createShapes(
lcl_getLegendEntries( xGroup, aEntryGroup, xLegendContainer,
m_xShapeFactory, xChartType,
aTextProperties,
- aMinEntryExtent, aMaxEntryExtent, aLegendIdentifier );
+ aMinEntryExtent, aMaxEntryExtent, aLegendIdentifier,
+ m_xModel );
}
}
diff --git a/chart2/source/view/main/VLegend.hxx b/chart2/source/view/main/VLegend.hxx
index 2b3c33401ae1..7d005175d034 100644
--- a/chart2/source/view/main/VLegend.hxx
+++ b/chart2/source/view/main/VLegend.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VLegend.hxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: iha $ $Date: 2003-12-04 15:46:54 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,6 +79,9 @@
#ifndef _DRAFTS_COM_SUN_STAR_LAYOUT_ALIGNMENT_HPP_
#include <drafts/com/sun/star/layout/Alignment.hpp>
#endif
+#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
+#include <com/sun/star/frame/XModel.hpp>
+#endif
//.............................................................................
namespace chart
@@ -98,7 +101,9 @@ public:
void SAL_CALL init( const ::com::sun::star::uno::Reference<
::com::sun::star::drawing::XShapes >& xTargetPage,
const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XMultiServiceFactory >& xFactory );
+ ::com::sun::star::lang::XMultiServiceFactory >& xFactory,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > & xModel );
void createShapes( const ::com::sun::star::awt::Size & rAvailableSpace,
const ::com::sun::star::awt::Size & rPageSize );
@@ -129,6 +134,8 @@ private:
::drafts::com::sun::star::chart2::XLegend > m_xLegend;
::com::sun::star::uno::Reference<
::com::sun::star::drawing::XShape > m_xShape;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > m_xModel;
};
//.............................................................................
diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx b/chart2/source/view/main/VLegendSymbolFactory.cxx
index 9d83070d89a2..efeb70bfa3ad 100644
--- a/chart2/source/view/main/VLegendSymbolFactory.cxx
+++ b/chart2/source/view/main/VLegendSymbolFactory.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: VLegendSymbolFactory.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: bm $ $Date: 2003-10-17 14:50:29 $
+ * last change: $Author: bm $ $Date: 2003-12-17 16:43:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -80,19 +80,28 @@ namespace
void lcl_setPropetiesToShape(
const uno::Reference< beans::XPropertySet > & xProp,
const uno::Reference< drawing::XShape > & xShape,
- bool bFilledSeries )
+ ::chart::VLegendSymbolFactory::tPropertyType ePropertyType )
{
- static ::chart::tPropertyNameMap aFilledNameMap( ::chart::PropertyMapper::getPropertyNameMapForFilledSeriesProperties());
- static ::chart::tPropertyNameMap aLineNameMap( ::chart::PropertyMapper::getPropertyNameMapForLineSeriesProperties());
+ static ::chart::tPropertyNameMap aFilledSeriesNameMap( ::chart::PropertyMapper::getPropertyNameMapForFilledSeriesProperties());
+ static ::chart::tPropertyNameMap aLineSeriesNameMap( ::chart::PropertyMapper::getPropertyNameMapForLineSeriesProperties());
+ static ::chart::tPropertyNameMap aLineNameMap( ::chart::PropertyMapper::getPropertyNameMapForLineProperties());
uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY );
if( xProp.is() && xShapeProp.is() )
{
::chart::tPropertyNameValueMap aValueMap;
- if( bFilledSeries )
- ::chart::PropertyMapper::getValueMap( aValueMap, aFilledNameMap, xProp );
- else
- ::chart::PropertyMapper::getValueMap( aValueMap, aLineNameMap, xProp );
+ switch( ePropertyType )
+ {
+ case ::chart::VLegendSymbolFactory::PROP_TYPE_FILLED_SERIES:
+ ::chart::PropertyMapper::getValueMap( aValueMap, aFilledSeriesNameMap, xProp );
+ break;
+ case ::chart::VLegendSymbolFactory::PROP_TYPE_LINE_SERIES:
+ ::chart::PropertyMapper::getValueMap( aValueMap, aLineSeriesNameMap, xProp );
+ break;
+ case ::chart::VLegendSymbolFactory::PROP_TYPE_LINE:
+ ::chart::PropertyMapper::getValueMap( aValueMap, aLineNameMap, xProp );
+ break;
+ }
::chart::tNameSequence aPropNames;
::chart::tAnySequence aPropValues;
@@ -111,7 +120,8 @@ void VLegendSymbolFactory::createSymbol(
const uno::Reference< drawing::XShapes > xSymbolGroup,
chart2::LegendSymbolStyle eStyle,
const uno::Reference< lang::XMultiServiceFactory > & xShapeFactory,
- const uno::Reference< beans::XPropertySet > & xSeriesProperties )
+ const uno::Reference< beans::XPropertySet > & xLegendEntryProperties,
+ tPropertyType ePropertyType )
{
// aspect ratio of symbols is always 3:2
awt::Size aBoundSize( 3000, 2000 );
@@ -195,7 +205,7 @@ void VLegendSymbolFactory::createSymbol(
}
}
- lcl_setPropetiesToShape( xSeriesProperties, xShape, true /* bFilledSeries */ );
+ lcl_setPropetiesToShape( xLegendEntryProperties, xShape, ePropertyType ); // PROP_TYPE_FILLED_SERIES );
#ifdef DISABLE_DASHES_AT_BORDER
// don't allow dashed border style
@@ -232,7 +242,7 @@ void VLegendSymbolFactory::createSymbol(
xLine->setSize( awt::Size( 3000, 0 ));
xLine->setPosition( awt::Point( 0, 1000 ));
- lcl_setPropetiesToShape( xSeriesProperties, xLine, false /* bFilledSeries */ );
+ lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); // PROP_TYPE_LINE_SERIES );
}
}
catch( uno::Exception & ex )
@@ -255,7 +265,7 @@ void VLegendSymbolFactory::createSymbol(
xLine->setSize( awt::Size( 2000, 2000 ));
xLine->setPosition( awt::Point( 500, 0 ));
- lcl_setPropetiesToShape( xSeriesProperties, xLine, false /* bFilledSeries */ );
+ lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); // PROP_TYPE_LINE_SERIES );
}
}
catch( uno::Exception & ex )
@@ -278,7 +288,7 @@ void VLegendSymbolFactory::createSymbol(
xLine->setSize( awt::Size( 3000, 0 ));
xLine->setPosition( awt::Point( 0, 1000 ));
- lcl_setPropetiesToShape( xSeriesProperties, xLine, false /* bFilledSeries */ );
+ lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); // PROP_TYPE_LINE_SERIES );
}
uno::Reference< drawing::XShape > xSymbol(
@@ -291,7 +301,7 @@ void VLegendSymbolFactory::createSymbol(
xSymbol->setSize( awt::Size( nSize, nSize ));
xSymbol->setPosition( awt::Point( 1500 - nSize/2, 1000 - nSize/2 ));
- lcl_setPropetiesToShape( xSeriesProperties, xSymbol, true /* bFilledSeries */ );
+ lcl_setPropetiesToShape( xLegendEntryProperties, xSymbol, ePropertyType ); // PROP_TYPE_FILLED_SERIES );
}
}
catch( uno::Exception & ex )