summaryrefslogtreecommitdiff
path: root/chart2/source/controller/itemsetwrapper
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2008-02-18 14:56:00 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2008-02-18 14:56:00 +0000
commit6950f6d82f0e9e5c445ddd68df4a1f19e89df26d (patch)
treeb9cd3f0c55ee96f6bf99cce48d93d50d04c74917 /chart2/source/controller/itemsetwrapper
parent7043319e894cd5f0dc25b7ff51ca494336dc0afc (diff)
INTEGRATION: CWS chart19 (1.2.8); FILE MERGED
2008/01/11 15:58:42 bm 1.2.8.1: #i44768# make it easier to add and modify trendlines
Diffstat (limited to 'chart2/source/controller/itemsetwrapper')
-rw-r--r--chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx89
1 files changed, 82 insertions, 7 deletions
diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index 31930bd77d09..7d9aba58066b 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: RegressionCurveItemConverter.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: ihi $ $Date: 2007-11-23 11:52:13 $
+ * last change: $Author: rt $ $Date: 2008-02-18 15:56:00 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -35,6 +35,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_chart2.hxx"
+#include "RegressionCurveHelper.hxx"
#include "RegressionCurveItemConverter.hxx"
#include "SchWhichPairs.hxx"
#include "macros.hxx"
@@ -45,12 +46,41 @@
// for SfxBoolItem
#include <svtools/eitem.hxx>
+#include <svx/chrtitem.hxx>
#include <functional>
#include <algorithm>
using namespace ::com::sun::star;
+namespace
+{
+
+::chart::RegressionCurveHelper::tRegressionType lcl_convertRegressionType( SvxChartRegress eRegress )
+{
+ ::chart::RegressionCurveHelper::tRegressionType eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_NONE;
+ switch( eRegress )
+ {
+ case CHREGRESS_LINEAR:
+ eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LINEAR;
+ break;
+ case CHREGRESS_LOG:
+ eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LOG;
+ break;
+ case CHREGRESS_EXP:
+ eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_EXP;
+ break;
+ case CHREGRESS_POWER:
+ eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POWER;
+ break;
+ case CHREGRESS_NONE:
+ break;
+ }
+ return eType;
+}
+
+} // anonymous namespace
+
namespace chart
{
namespace wrapper
@@ -58,6 +88,7 @@ namespace wrapper
RegressionCurveItemConverter::RegressionCurveItemConverter(
const uno::Reference< beans::XPropertySet > & rPropertySet,
+ const uno::Reference< chart2::XRegressionCurveContainer > & xRegCurveCnt,
SfxItemPool& rItemPool,
SdrModel& rDrawModel,
const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) :
@@ -65,7 +96,8 @@ RegressionCurveItemConverter::RegressionCurveItemConverter(
m_spGraphicConverter( new GraphicPropertyItemConverter(
rPropertySet, rItemPool, rDrawModel,
xNamedPropertyContainerFactory,
- GraphicPropertyItemConverter::LINE_PROPERTIES ))
+ GraphicPropertyItemConverter::LINE_PROPERTIES )),
+ m_xCurveContainer( xRegCurveCnt )
{}
RegressionCurveItemConverter::~RegressionCurveItemConverter()
@@ -105,13 +137,45 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
USHORT nWhichId, const SfxItemSet & rItemSet )
throw( uno::Exception )
{
+ uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
bool bChanged = false;
switch( nWhichId )
{
+ case SCHATTR_STAT_REGRESSTYPE:
+ {
+ OSL_ASSERT( xCurve.is());
+ if( xCurve.is())
+ {
+ SvxChartRegress eRegress = static_cast< SvxChartRegress >(
+ static_cast< sal_Int32 >( RegressionCurveHelper::getRegressionType( xCurve )));
+ SvxChartRegress eNewRegress = static_cast< const SvxChartRegressItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ if( eRegress != eNewRegress )
+ {
+ // note that changing the regression type changes the object
+ // 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,
+ 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;
+ }
+ }
+ }
+ }
+ break;
+
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
- uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
OSL_ASSERT( xCurve.is());
if( xCurve.is())
{
@@ -135,7 +199,6 @@ bool RegressionCurveItemConverter::ApplySpecialItem(
case SCHATTR_REGRESSION_SHOW_COEFF:
{
- uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
OSL_ASSERT( xCurve.is());
if( xCurve.is())
{
@@ -165,11 +228,24 @@ void RegressionCurveItemConverter::FillSpecialItem(
USHORT nWhichId, SfxItemSet & rOutItemSet ) const
throw( uno::Exception )
{
+ uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
+
switch( nWhichId )
{
+ case SCHATTR_STAT_REGRESSTYPE:
+ {
+ OSL_ASSERT( xCurve.is());
+ if( xCurve.is())
+ {
+ SvxChartRegress eRegress = static_cast< SvxChartRegress >(
+ static_cast< sal_Int32 >( RegressionCurveHelper::getRegressionType( xCurve )));
+ rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_STAT_REGRESSTYPE ));
+ }
+ }
+ break;
+
case SCHATTR_REGRESSION_SHOW_EQUATION:
{
- uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
OSL_ASSERT( xCurve.is());
if( xCurve.is())
{
@@ -187,7 +263,6 @@ void RegressionCurveItemConverter::FillSpecialItem(
case SCHATTR_REGRESSION_SHOW_COEFF:
{
- uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
OSL_ASSERT( xCurve.is());
if( xCurve.is())
{