summaryrefslogtreecommitdiff
path: root/chart2/source/controller/itemsetwrapper
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/itemsetwrapper')
-rw-r--r--chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx1008
-rw-r--r--chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx579
-rw-r--r--chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx702
-rw-r--r--chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx459
-rw-r--r--chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx794
-rw-r--r--chart2/source/controller/itemsetwrapper/ItemConverter.cxx270
-rw-r--r--chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx206
-rw-r--r--chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx236
-rw-r--r--chart2/source/controller/itemsetwrapper/MultipleItemConverter.cxx87
-rw-r--r--chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx279
-rw-r--r--chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx172
-rw-r--r--chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx241
-rw-r--r--chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx456
-rw-r--r--chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx700
-rw-r--r--chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx248
-rw-r--r--chart2/source/controller/itemsetwrapper/makefile.mk60
16 files changed, 6497 insertions, 0 deletions
diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
new file mode 100644
index 000000000000..4eb1a92d21c0
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
@@ -0,0 +1,1008 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+#include "AxisItemConverter.hxx"
+#include "ItemPropertyMap.hxx"
+#include "CharacterPropertyItemConverter.hxx"
+#include "GraphicPropertyItemConverter.hxx"
+#include "chartview/ChartSfxItemIds.hxx"
+#include "chartview/ExplicitValueProvider.hxx"
+#include "SchWhichPairs.hxx"
+#include "macros.hxx"
+#include "ChartModelHelper.hxx"
+#include "AxisHelper.hxx"
+#include "CommonConverters.hxx"
+#include "ChartTypeHelper.hxx"
+
+#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
+#include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
+#include <com/sun/star/chart/ChartAxisPosition.hpp>
+#include <com/sun/star/chart2/XAxis.hpp>
+#include <com/sun/star/chart2/AxisOrientation.hpp>
+#include <com/sun/star/chart2/AxisType.hpp>
+
+// for SfxBoolItem
+#include <svl/eitem.hxx>
+// for SvxDoubleItem
+#include <svx/chrtitem.hxx>
+// for SfxInt32Item
+#include <svl/intitem.hxx>
+#include <rtl/math.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::chart::TimeInterval;
+using ::com::sun::star::chart::TimeIncrement;
+
+namespace
+{
+::comphelper::ItemPropertyMapType & lcl_GetAxisPropertyMap()
+{
+ static ::comphelper::ItemPropertyMapType aAxisPropertyMap(
+ ::comphelper::MakeItemPropertyMap
+ IPM_MAP_ENTRY( SCHATTR_AXIS_SHOWDESCR, "DisplayLabels", 0 )
+ IPM_MAP_ENTRY( SCHATTR_AXIS_TICKS, "MajorTickmarks", 0 )
+ IPM_MAP_ENTRY( SCHATTR_AXIS_HELPTICKS, "MinorTickmarks", 0 )
+ IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_ORDER, "ArrangeOrder", 0 )
+ IPM_MAP_ENTRY( SCHATTR_TEXT_STACKED, "StackCharacters", 0 )
+ IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_BREAK, "TextBreak", 0 )
+ IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_OVERLAP, "TextOverlap", 0 )
+ );
+
+ return aAxisPropertyMap;
+};
+} // anonymous namespace
+
+namespace chart
+{
+namespace wrapper
+{
+
+AxisItemConverter::AxisItemConverter(
+ const Reference< beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ const Reference< chart2::XChartDocument > & xChartDoc,
+ ::chart::ExplicitScaleData * pScale /* = NULL */,
+ ::chart::ExplicitIncrementData * pIncrement /* = NULL */,
+ ::std::auto_ptr< awt::Size > pRefSize /* = NULL */ ) :
+ ItemConverter( rPropertySet, rItemPool ),
+ m_xChartDoc( xChartDoc ),
+ m_pExplicitScale( NULL ),
+ m_pExplicitIncrement( NULL )
+{
+ Reference< lang::XMultiServiceFactory > xNamedPropertyContainerFactory( xChartDoc, uno::UNO_QUERY );
+
+ if( pScale )
+ m_pExplicitScale = new ::chart::ExplicitScaleData( *pScale );
+ if( pIncrement )
+ m_pExplicitIncrement = new ::chart::ExplicitIncrementData( *pIncrement );
+
+ m_aConverters.push_back( new GraphicPropertyItemConverter(
+ rPropertySet, rItemPool, rDrawModel,
+ xNamedPropertyContainerFactory,
+ GraphicPropertyItemConverter::LINE_PROPERTIES ));
+ m_aConverters.push_back( new CharacterPropertyItemConverter( rPropertySet, rItemPool, pRefSize,
+ C2U( "ReferencePageSize" ) ));
+
+ m_xAxis.set( Reference< chart2::XAxis >( rPropertySet, uno::UNO_QUERY ) );
+ OSL_ASSERT( m_xAxis.is());
+}
+
+AxisItemConverter::~AxisItemConverter()
+{
+ delete m_pExplicitScale;
+ delete m_pExplicitIncrement;
+
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::DeleteItemConverterPtr() );
+}
+
+void AxisItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::FillItemSetFunc( rOutItemSet ));
+
+ // own items
+ ItemConverter::FillItemSet( rOutItemSet );
+}
+
+bool AxisItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
+{
+ bool bResult = false;
+
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::ApplyItemSetFunc( rItemSet, bResult ));
+
+ // own items
+ return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
+}
+
+const sal_uInt16 * AxisItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nAxisWhichPairs;
+}
+
+bool AxisItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
+{
+ ::comphelper::ItemPropertyMapType & rMap( lcl_GetAxisPropertyMap());
+ ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
+
+ if( aIt == rMap.end())
+ return false;
+
+ rOutProperty =(*aIt).second;
+
+ return true;
+}
+
+bool lcl_hasTimeIntervalValue( const uno::Any& rAny )
+{
+ bool bRet = false;
+ TimeInterval aValue;
+ if( rAny >>= aValue )
+ bRet = true;
+ return bRet;
+}
+
+void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+ throw( uno::Exception )
+{
+ if( !m_xAxis.is() )
+ return;
+
+ const chart2::ScaleData& rScale( m_xAxis->getScaleData() );
+ const chart2::IncrementData& rIncrement( rScale.IncrementData );
+ const uno::Sequence< chart2::SubIncrement >& rSubIncrements( rScale.IncrementData.SubIncrements );
+ const TimeIncrement& rTimeIncrement( rScale.TimeIncrement );
+ bool bDateAxis = (chart2::AxisType::DATE == rScale.AxisType);
+ if( m_pExplicitScale )
+ bDateAxis = (chart2::AxisType::DATE == m_pExplicitScale->AxisType);
+
+ switch( nWhichId )
+ {
+ case SCHATTR_AXIS_AUTO_MAX:
+ rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rScale.Maximum) ) );
+ break;
+
+ case SCHATTR_AXIS_MAX:
+ {
+ double fMax = 10.0;
+ if( rScale.Maximum >>= fMax )
+ rOutItemSet.Put( SvxDoubleItem( fMax, nWhichId ) );
+ else
+ {
+ if( m_pExplicitScale )
+ fMax = m_pExplicitScale->Maximum;
+ rOutItemSet.Put( SvxDoubleItem( fMax, nWhichId ) );
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_AUTO_MIN:
+ rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rScale.Minimum) ) );
+ break;
+
+ case SCHATTR_AXIS_MIN:
+ {
+ double fMin = 0.0;
+ if( rScale.Minimum >>= fMin )
+ rOutItemSet.Put( SvxDoubleItem( fMin, nWhichId ) );
+ else if( m_pExplicitScale )
+ rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, nWhichId ));
+ }
+ break;
+
+ case SCHATTR_AXIS_LOGARITHM:
+ {
+ sal_Bool bValue = AxisHelper::isLogarithmic( rScale.Scaling );
+ rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
+ }
+ break;
+
+ case SCHATTR_AXIS_REVERSE:
+ rOutItemSet.Put( SfxBoolItem( nWhichId, (AxisOrientation_REVERSE == rScale.Orientation) ));
+ break;
+
+ // Increment
+ case SCHATTR_AXIS_AUTO_STEP_MAIN:
+ if( bDateAxis )
+ rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MajorTimeInterval) ) );
+ else
+ rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rIncrement.Distance) ) );
+ break;
+
+ case SCHATTR_AXIS_MAIN_TIME_UNIT:
+ {
+ TimeInterval aTimeInterval;
+ if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) );
+ else if( m_pExplicitIncrement )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MajorTimeInterval.TimeUnit ) );
+ }
+ break;
+
+ case SCHATTR_AXIS_STEP_MAIN:
+ if( bDateAxis )
+ {
+ TimeInterval aTimeInterval;
+ if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval )
+ rOutItemSet.Put( SvxDoubleItem(aTimeInterval.Number, nWhichId ));
+ else if( m_pExplicitIncrement )
+ rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->MajorTimeInterval.Number, nWhichId ));
+ }
+ else
+ {
+ double fDistance = 1.0;
+ if( rIncrement.Distance >>= fDistance )
+ rOutItemSet.Put( SvxDoubleItem(fDistance, nWhichId ));
+ else if( m_pExplicitIncrement )
+ rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, nWhichId ));
+ }
+ break;
+
+ // SubIncrement
+ case SCHATTR_AXIS_AUTO_STEP_HELP:
+ if( bDateAxis )
+ rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MinorTimeInterval) ) );
+ else
+ rOutItemSet.Put( SfxBoolItem( nWhichId,
+ ! ( rSubIncrements.getLength() > 0 && rSubIncrements[0].IntervalCount.hasValue() )));
+ break;
+
+ case SCHATTR_AXIS_HELP_TIME_UNIT:
+ {
+ TimeInterval aTimeInterval;
+ if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) );
+ else if( m_pExplicitIncrement )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.TimeUnit ) );
+ }
+ break;
+
+ case SCHATTR_AXIS_STEP_HELP:
+ if( bDateAxis )
+ {
+ TimeInterval aTimeInterval;
+ if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.Number ));
+ else if( m_pExplicitIncrement )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.Number ));
+ }
+ else
+ {
+ if( rSubIncrements.getLength() > 0 && rSubIncrements[0].IntervalCount.hasValue())
+ {
+ OSL_ASSERT( rSubIncrements[0].IntervalCount.getValueTypeClass() == uno::TypeClass_LONG );
+ rOutItemSet.Put( SfxInt32Item( nWhichId,
+ *reinterpret_cast< const sal_Int32 * >(
+ rSubIncrements[0].IntervalCount.getValue()) ));
+ }
+ else
+ {
+ if( m_pExplicitIncrement && !m_pExplicitIncrement->SubIncrements.empty() )
+ {
+ rOutItemSet.Put( SfxInt32Item( nWhichId,
+ m_pExplicitIncrement->SubIncrements[0].IntervalCount ));
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_AUTO_TIME_RESOLUTION:
+ {
+ rOutItemSet.Put( SfxBoolItem( nWhichId,
+ !rTimeIncrement.TimeResolution.hasValue() ));
+ }
+ break;
+ case SCHATTR_AXIS_TIME_RESOLUTION:
+ {
+ long nTimeResolution=0;
+ if( rTimeIncrement.TimeResolution >>= nTimeResolution )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, nTimeResolution ) );
+ else if( m_pExplicitScale )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitScale->TimeResolution ) );
+ }
+ break;
+
+ case SCHATTR_AXIS_AUTO_ORIGIN:
+ {
+ rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(rScale.Origin) )));
+ }
+ break;
+
+ case SCHATTR_AXIS_ORIGIN:
+ {
+ double fOrigin = 0.0;
+ if( !(rScale.Origin >>= fOrigin) )
+ {
+ if( m_pExplicitScale )
+ fOrigin = m_pExplicitScale->Origin;
+ }
+ rOutItemSet.Put( SvxDoubleItem( fOrigin, nWhichId ));
+ }
+ break;
+
+ case SCHATTR_AXIS_POSITION:
+ {
+ ::com::sun::star::chart::ChartAxisPosition eAxisPos( ::com::sun::star::chart::ChartAxisPosition_ZERO );
+ GetPropertySet()->getPropertyValue(C2U( "CrossoverPosition" )) >>= eAxisPos;
+ rOutItemSet.Put( SfxInt32Item( nWhichId, eAxisPos ) );
+ }
+ break;
+
+ case SCHATTR_AXIS_POSITION_VALUE:
+ {
+ double fValue = 0.0;
+ if( GetPropertySet()->getPropertyValue(C2U( "CrossoverValue" )) >>= fValue )
+ rOutItemSet.Put( SvxDoubleItem( fValue, nWhichId ) );
+ }
+ break;
+
+ case SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT:
+ {
+ //read only item
+ //necessary tp display the crossing value with an appropriate format
+
+ Reference< chart2::XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis(
+ m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) );
+
+ Reference< chart2::XAxis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ) );
+
+ sal_Int32 nFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
+ xCrossingMainAxis, xCooSys, Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ) );
+
+ rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey ));
+ }
+ break;
+
+ case SCHATTR_AXIS_LABEL_POSITION:
+ {
+ ::com::sun::star::chart::ChartAxisLabelPosition ePos( ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS );
+ GetPropertySet()->getPropertyValue(C2U( "LabelPosition" )) >>= ePos;
+ rOutItemSet.Put( SfxInt32Item( nWhichId, ePos ) );
+ }
+ break;
+
+ case SCHATTR_AXIS_MARK_POSITION:
+ {
+ ::com::sun::star::chart::ChartAxisMarkPosition ePos( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS );
+ GetPropertySet()->getPropertyValue(C2U( "MarkPosition" )) >>= ePos;
+ rOutItemSet.Put( SfxInt32Item( nWhichId, ePos ) );
+ }
+ break;
+
+ case SCHATTR_TEXT_DEGREES:
+ {
+ // convert double to int (times 100)
+ double fVal = 0;
+
+ if( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fVal )
+ {
+ rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >(
+ ::rtl::math::round( fVal * 100.0 ) ) ));
+ }
+ }
+ break;
+
+ case SID_ATTR_NUMBERFORMAT_VALUE:
+ {
+ if( m_pExplicitScale )
+ {
+ Reference< chart2::XCoordinateSystem > xCooSys(
+ AxisHelper::getCoordinateSystemOfAxis(
+ m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) );
+
+ sal_Int32 nFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
+ m_xAxis, xCooSys, Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ) );
+
+ rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey ));
+ }
+ }
+ break;
+
+ case SID_ATTR_NUMBERFORMAT_SOURCE:
+ {
+ bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )).hasValue());
+ rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
+ }
+ break;
+
+ case SCHATTR_AXISTYPE:
+ rOutItemSet.Put( SfxInt32Item( nWhichId, rScale.AxisType ));
+ break;
+
+ case SCHATTR_AXIS_AUTO_DATEAXIS:
+ rOutItemSet.Put( SfxBoolItem( nWhichId, rScale.AutoDateAxis ));
+ break;
+
+ case SCHATTR_AXIS_ALLOW_DATEAXIS:
+ {
+ Reference< chart2::XCoordinateSystem > xCooSys(
+ AxisHelper::getCoordinateSystemOfAxis( m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) );
+ sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0;
+ AxisHelper::getIndicesForAxis(m_xAxis, xCooSys, nDimensionIndex, nAxisIndex );
+ bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), 2, nDimensionIndex );
+ rOutItemSet.Put( SfxBoolItem( nWhichId, bChartTypeAllowsDateAxis ));
+ }
+ break;
+ }
+}
+
+bool lcl_isDateAxis( const SfxItemSet & rItemSet )
+{
+ sal_Int32 nAxisType = static_cast< const SfxInt32Item & >( rItemSet.Get( SCHATTR_AXISTYPE )).GetValue();//::com::sun::star::chart2::AxisType
+ return (chart2::AxisType::DATE == nAxisType);
+}
+
+bool lcl_isAutoMajor( const SfxItemSet & rItemSet )
+{
+ bool bRet = static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_MAIN )).GetValue();
+ return bRet;
+}
+
+bool lcl_isAutoMinor( const SfxItemSet & rItemSet )
+{
+ bool bRet = static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_HELP )).GetValue();
+ return bRet;
+}
+
+bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
+ throw( uno::Exception )
+{
+ if( !m_xAxis.is() )
+ return false;
+
+ chart2::ScaleData aScale( m_xAxis->getScaleData() );
+
+ bool bSetScale = false;
+ bool bChangedOtherwise = false;
+
+ uno::Any aValue;
+
+ switch( nWhichId )
+ {
+ case SCHATTR_AXIS_AUTO_MAX:
+ if( (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue() ))
+ {
+ aScale.Maximum.clear();
+ bSetScale = true;
+ }
+ // else SCHATTR_AXIS_MAX must have some value
+ break;
+
+ case SCHATTR_AXIS_MAX:
+ // only if auto if false
+ if( ! (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( SCHATTR_AXIS_AUTO_MAX )).GetValue() ))
+ {
+ rItemSet.Get( nWhichId ).QueryValue( aValue );
+
+ if( aScale.Maximum != aValue )
+ {
+ aScale.Maximum = aValue;
+ bSetScale = true;
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_AUTO_MIN:
+ if( (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue() ))
+ {
+ aScale.Minimum.clear();
+ bSetScale = true;
+ }
+ // else SCHATTR_AXIS_MIN must have some value
+ break;
+
+ case SCHATTR_AXIS_MIN:
+ // only if auto if false
+ if( ! (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( SCHATTR_AXIS_AUTO_MIN )).GetValue() ))
+ {
+ rItemSet.Get( nWhichId ).QueryValue( aValue );
+
+ if( aScale.Minimum != aValue )
+ {
+ aScale.Minimum = aValue;
+ bSetScale = true;
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_LOGARITHM:
+ {
+ bool bWasLogarithm = AxisHelper::isLogarithmic( aScale.Scaling );
+
+ if( (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue() ))
+ {
+ // logarithm is true
+ if( ! bWasLogarithm )
+ {
+ aScale.Scaling = AxisHelper::createLogarithmicScaling( 10.0 );
+ bSetScale = true;
+ }
+ }
+ else
+ {
+ // logarithm is false => linear scaling
+ if( bWasLogarithm )
+ {
+ aScale.Scaling = AxisHelper::createLinearScaling();
+ bSetScale = true;
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_REVERSE:
+ {
+ bool bWasReverse = ( AxisOrientation_REVERSE == aScale.Orientation );
+ bool bNewReverse = (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue() );
+ if( bWasReverse != bNewReverse )
+ {
+ aScale.Orientation = bNewReverse ? AxisOrientation_REVERSE : AxisOrientation_MATHEMATICAL;
+ bSetScale = true;
+ }
+ }
+ break;
+
+ // Increment
+ case SCHATTR_AXIS_AUTO_STEP_MAIN:
+ if( lcl_isAutoMajor(rItemSet) )
+ {
+ aScale.IncrementData.Distance.clear();
+ aScale.TimeIncrement.MajorTimeInterval.clear();
+ bSetScale = true;
+ }
+ // else SCHATTR_AXIS_STEP_MAIN must have some value
+ break;
+
+ case SCHATTR_AXIS_MAIN_TIME_UNIT:
+ if( !lcl_isAutoMajor(rItemSet) )
+ {
+ if( rItemSet.Get( nWhichId ).QueryValue( aValue ) )
+ {
+ TimeInterval aTimeInterval;
+ aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval;
+ aValue >>= aTimeInterval.TimeUnit;
+ aScale.TimeIncrement.MajorTimeInterval = uno::makeAny( aTimeInterval );
+ bSetScale = true;
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_STEP_MAIN:
+ // only if auto if false
+ if( !lcl_isAutoMajor(rItemSet) )
+ {
+ rItemSet.Get( nWhichId ).QueryValue( aValue );
+ if( lcl_isDateAxis(rItemSet) )
+ {
+ double fValue = 1.0;
+ if( aValue >>= fValue )
+ {
+ TimeInterval aTimeInterval;
+ aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval;
+ aTimeInterval.Number = static_cast<double>(fValue);
+ aScale.TimeIncrement.MajorTimeInterval = uno::makeAny( aTimeInterval );
+ bSetScale = true;
+ }
+ }
+ else if( aScale.IncrementData.Distance != aValue )
+ {
+ aScale.IncrementData.Distance = aValue;
+ bSetScale = true;
+ }
+ }
+ break;
+
+ // SubIncrement
+ case SCHATTR_AXIS_AUTO_STEP_HELP:
+ if( lcl_isAutoMinor(rItemSet) )
+ {
+ if( aScale.IncrementData.SubIncrements.getLength() > 0 &&
+ aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() )
+ {
+ aScale.IncrementData.SubIncrements[0].IntervalCount.clear();
+ bSetScale = true;
+ }
+ if( aScale.TimeIncrement.MinorTimeInterval.hasValue() )
+ {
+ aScale.TimeIncrement.MinorTimeInterval.clear();
+ bSetScale = true;
+ }
+ }
+ // else SCHATTR_AXIS_STEP_MAIN must have some value
+ break;
+
+ case SCHATTR_AXIS_HELP_TIME_UNIT:
+ if( !lcl_isAutoMinor(rItemSet) )
+ {
+ if( rItemSet.Get( nWhichId ).QueryValue( aValue ) )
+ {
+ TimeInterval aTimeInterval;
+ aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval;
+ aValue >>= aTimeInterval.TimeUnit;
+ aScale.TimeIncrement.MinorTimeInterval = uno::makeAny( aTimeInterval );
+ bSetScale = true;
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_STEP_HELP:
+ // only if auto is false
+ if( !lcl_isAutoMinor(rItemSet) )
+ {
+ rItemSet.Get( nWhichId ).QueryValue( aValue );
+ if( lcl_isDateAxis(rItemSet) )
+ {
+ TimeInterval aTimeInterval;
+ aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval;
+ aValue >>= aTimeInterval.Number;
+ aScale.TimeIncrement.MinorTimeInterval = uno::makeAny(aTimeInterval);
+ bSetScale = true;
+ }
+ else if( aScale.IncrementData.SubIncrements.getLength() > 0 )
+ {
+ if( ! aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ||
+ aScale.IncrementData.SubIncrements[0].IntervalCount != aValue )
+ {
+ OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG );
+ aScale.IncrementData.SubIncrements[0].IntervalCount = aValue;
+ bSetScale = true;
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_AUTO_TIME_RESOLUTION:
+ if( (static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue() ))
+ {
+ aScale.TimeIncrement.TimeResolution.clear();
+ bSetScale = true;
+ }
+ break;
+ case SCHATTR_AXIS_TIME_RESOLUTION:
+ // only if auto is false
+ if( ! (static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_TIME_RESOLUTION )).GetValue() ))
+ {
+ rItemSet.Get( nWhichId ).QueryValue( aValue );
+
+ if( aScale.TimeIncrement.TimeResolution != aValue )
+ {
+ aScale.TimeIncrement.TimeResolution = aValue;
+ bSetScale = true;
+ }
+ }
+ break;
+
+
+ case SCHATTR_AXIS_AUTO_ORIGIN:
+ {
+ if( (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue() ))
+ {
+ aScale.Origin.clear();
+ bSetScale = true;
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_ORIGIN:
+ {
+ // only if auto is false
+ if( ! (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( SCHATTR_AXIS_AUTO_ORIGIN )).GetValue() ))
+ {
+ rItemSet.Get( nWhichId ).QueryValue( aValue );
+
+ if( aScale.Origin != aValue )
+ {
+ aScale.Origin = aValue;
+ bSetScale = true;
+
+ if( !AxisHelper::isAxisPositioningEnabled() )
+ {
+ //keep old and new settings for axis positioning in sync somehow
+ Reference< chart2::XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis(
+ m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) );
+
+ sal_Int32 nDimensionIndex=0;
+ sal_Int32 nAxisIndex=0;
+ if( AxisHelper::getIndicesForAxis( m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ) && nAxisIndex==0 )
+ {
+ Reference< beans::XPropertySet > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ), uno::UNO_QUERY );
+ if( xCrossingMainAxis.is() )
+ {
+ double fValue = 0.0;
+ if( aValue >>= fValue )
+ {
+ xCrossingMainAxis->setPropertyValue( C2U( "CrossoverPosition" ), uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE ));
+ xCrossingMainAxis->setPropertyValue( C2U( "CrossoverValue" ), uno::makeAny( fValue ));
+ }
+ else
+ xCrossingMainAxis->setPropertyValue( C2U( "CrossoverPosition" ), uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START ));
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_POSITION:
+ {
+ ::com::sun::star::chart::ChartAxisPosition eAxisPos =
+ (::com::sun::star::chart::ChartAxisPosition)
+ static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
+
+ ::com::sun::star::chart::ChartAxisPosition eOldAxisPos( ::com::sun::star::chart::ChartAxisPosition_ZERO );
+ bool bPropExisted = ( GetPropertySet()->getPropertyValue(C2U( "CrossoverPosition" )) >>= eOldAxisPos );
+
+ if( !bPropExisted || ( eOldAxisPos != eAxisPos ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CrossoverPosition" ), uno::makeAny( eAxisPos ));
+ bChangedOtherwise = true;
+
+ //move the parallel axes to the other side if necessary
+ if( eAxisPos==::com::sun::star::chart::ChartAxisPosition_START || eAxisPos==::com::sun::star::chart::ChartAxisPosition_END )
+ {
+ Reference< beans::XPropertySet > xParallelAxis( AxisHelper::getParallelAxis( m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ), uno::UNO_QUERY );
+ if( xParallelAxis.is() )
+ {
+ ::com::sun::star::chart::ChartAxisPosition eOtherPos;
+ if( xParallelAxis->getPropertyValue( C2U( "CrossoverPosition" ) ) >>= eOtherPos )
+ {
+ if( eOtherPos == eAxisPos )
+ {
+ ::com::sun::star::chart::ChartAxisPosition eOppositePos =
+ (eAxisPos==::com::sun::star::chart::ChartAxisPosition_START)
+ ? ::com::sun::star::chart::ChartAxisPosition_END
+ : ::com::sun::star::chart::ChartAxisPosition_START;
+ xParallelAxis->setPropertyValue( C2U( "CrossoverPosition" ), uno::makeAny( eOppositePos ));
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_POSITION_VALUE:
+ {
+ double fValue = static_cast< const SvxDoubleItem & >( rItemSet.Get( nWhichId )).GetValue();
+
+ double fOldValue = 0.0;
+ bool bPropExisted = ( GetPropertySet()->getPropertyValue(C2U( "CrossoverValue" )) >>= fOldValue );
+
+ if( !bPropExisted || ( fOldValue != fValue ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CrossoverValue" ), uno::makeAny( fValue ));
+ bChangedOtherwise = true;
+
+ //keep old and new settings for axis positioning in sync somehow
+ {
+ Reference< chart2::XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis(
+ m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) );
+
+ sal_Int32 nDimensionIndex=0;
+ sal_Int32 nAxisIndex=0;
+ if( AxisHelper::getIndicesForAxis( m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ) && nAxisIndex==0 && nDimensionIndex==0 )
+ {
+ Reference< chart2::XAxis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ) );
+ if( xCrossingMainAxis.is() )
+ {
+ ScaleData aCrossingScale( xCrossingMainAxis->getScaleData() );
+ aCrossingScale.Origin = uno::makeAny(fValue);
+ xCrossingMainAxis->setScaleData(aCrossingScale);
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_LABEL_POSITION:
+ {
+ ::com::sun::star::chart::ChartAxisLabelPosition ePos =
+ (::com::sun::star::chart::ChartAxisLabelPosition)
+ static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
+
+ ::com::sun::star::chart::ChartAxisLabelPosition eOldPos( ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS );
+ bool bPropExisted = ( GetPropertySet()->getPropertyValue(C2U( "LabelPosition" )) >>= eOldPos );
+
+ if( !bPropExisted || ( eOldPos != ePos ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "LabelPosition" ), uno::makeAny( ePos ));
+ bChangedOtherwise = true;
+
+ //move the parallel axes to the other side if necessary
+ if( ePos==::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START || ePos==::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END )
+ {
+ Reference< beans::XPropertySet > xParallelAxis( AxisHelper::getParallelAxis( m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ), uno::UNO_QUERY );
+ if( xParallelAxis.is() )
+ {
+ ::com::sun::star::chart::ChartAxisLabelPosition eOtherPos;
+ if( xParallelAxis->getPropertyValue( C2U( "LabelPosition" ) ) >>= eOtherPos )
+ {
+ if( eOtherPos == ePos )
+ {
+ ::com::sun::star::chart::ChartAxisLabelPosition eOppositePos =
+ (ePos==::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START)
+ ? ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END
+ : ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START;
+ xParallelAxis->setPropertyValue( C2U( "LabelPosition" ), uno::makeAny( eOppositePos ));
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_AXIS_MARK_POSITION:
+ {
+ ::com::sun::star::chart::ChartAxisMarkPosition ePos =
+ (::com::sun::star::chart::ChartAxisMarkPosition)
+ static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
+
+ ::com::sun::star::chart::ChartAxisMarkPosition eOldPos( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS );
+ bool bPropExisted = ( GetPropertySet()->getPropertyValue(C2U( "MarkPosition" )) >>= eOldPos );
+
+ if( !bPropExisted || ( eOldPos != ePos ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "MarkPosition" ), uno::makeAny( ePos ));
+ bChangedOtherwise = true;
+ }
+ }
+ break;
+
+ case SCHATTR_TEXT_DEGREES:
+ {
+ // convert int to double (divided by 100)
+ double fVal = static_cast< double >(
+ static_cast< const SfxInt32Item & >(
+ rItemSet.Get( nWhichId )).GetValue()) / 100.0;
+ double fOldVal = 0.0;
+ bool bPropExisted =
+ ( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fOldVal );
+
+ if( ! bPropExisted ||
+ ( bPropExisted && fOldVal != fVal ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "TextRotation" ), uno::makeAny( fVal ));
+ bChangedOtherwise = true;
+ }
+ }
+ break;
+
+ case SID_ATTR_NUMBERFORMAT_VALUE:
+ {
+ if( m_pExplicitScale )
+ {
+ bool bUseSourceFormat =
+ (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( SID_ATTR_NUMBERFORMAT_SOURCE )).GetValue() );
+
+ if( ! bUseSourceFormat )
+ {
+ sal_Int32 nFmt = static_cast< sal_Int32 >(
+ static_cast< const SfxUInt32Item & >(
+ rItemSet.Get( nWhichId )).GetValue());
+
+ aValue = uno::makeAny(nFmt);
+ if( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) != aValue )
+ {
+ GetPropertySet()->setPropertyValue( C2U( "NumberFormat" ), aValue );
+ bChangedOtherwise = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case SID_ATTR_NUMBERFORMAT_SOURCE:
+ {
+ bool bUseSourceFormat =
+ (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue() );
+ bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )).hasValue());
+
+ bChangedOtherwise = (bUseSourceFormat == bNumberFormatIsSet);
+ if( bChangedOtherwise )
+ {
+ if( ! bUseSourceFormat )
+ {
+ SfxItemState aState = rItemSet.GetItemState( SID_ATTR_NUMBERFORMAT_VALUE );
+ if( aState == SFX_ITEM_SET )
+ {
+ sal_Int32 nFormatKey = static_cast< sal_Int32 >(
+ static_cast< const SfxUInt32Item & >(
+ rItemSet.Get( SID_ATTR_NUMBERFORMAT_VALUE )).GetValue());
+ aValue <<= nFormatKey;
+ }
+ else
+ {
+ Reference< chart2::XCoordinateSystem > xCooSys(
+ AxisHelper::getCoordinateSystemOfAxis(
+ m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) );
+
+ sal_Int32 nFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
+ m_xAxis, xCooSys, Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ) );
+
+ aValue <<= nFormatKey;
+ }
+ }
+ // else set a void Any
+ GetPropertySet()->setPropertyValue( C2U( "NumberFormat" ), aValue );
+ }
+ }
+ break;
+
+ case SCHATTR_AXISTYPE:
+ {
+ sal_Int32 nNewAxisType = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();//::com::sun::star::chart2::AxisType
+ aScale.AxisType = nNewAxisType;
+ bSetScale = true;
+ }
+ break;
+
+ case SCHATTR_AXIS_AUTO_DATEAXIS:
+ {
+ bool bNewValue = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
+ bool bOldValue = aScale.AutoDateAxis;
+ if( bOldValue != bNewValue )
+ {
+ aScale.AutoDateAxis = bNewValue;
+ bSetScale = true;
+ }
+ }
+ break;
+ }
+
+ if( bSetScale )
+ m_xAxis->setScaleData( aScale );
+
+ return (bSetScale || bChangedOtherwise);
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx
new file mode 100644
index 000000000000..4597499f7032
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx
@@ -0,0 +1,579 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+#include "CharacterPropertyItemConverter.hxx"
+#include "SchWhichPairs.hxx"
+#include "macros.hxx"
+#include "ItemPropertyMap.hxx"
+#include "RelativeSizeHelper.hxx"
+#include <editeng/memberids.hrc>
+#include <editeng/eeitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <svl/stritem.hxx>
+
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/chart2/XFormattedString.hpp>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+::comphelper::ItemPropertyMapType & lcl_GetCharacterPropertyPropertyMap()
+{
+ static ::comphelper::ItemPropertyMapType aCharacterPropertyMap(
+ ::comphelper::MakeItemPropertyMap
+ IPM_MAP_ENTRY( EE_CHAR_COLOR, "CharColor", 0 )
+ IPM_MAP_ENTRY( EE_CHAR_LANGUAGE, "CharLocale", MID_LANG_LOCALE )
+ IPM_MAP_ENTRY( EE_CHAR_LANGUAGE_CJK, "CharLocaleAsian", MID_LANG_LOCALE )
+ IPM_MAP_ENTRY( EE_CHAR_LANGUAGE_CTL, "CharLocaleComplex", MID_LANG_LOCALE )
+
+ IPM_MAP_ENTRY( EE_CHAR_STRIKEOUT, "CharStrikeout", MID_CROSS_OUT )
+ IPM_MAP_ENTRY( EE_CHAR_WLM, "CharWordMode", 0 )
+ IPM_MAP_ENTRY( EE_CHAR_SHADOW, "CharShadowed", 0 )
+ IPM_MAP_ENTRY( EE_CHAR_RELIEF, "CharRelief", 0 )
+ IPM_MAP_ENTRY( EE_CHAR_OUTLINE, "CharContoured", 0 )
+ IPM_MAP_ENTRY( EE_CHAR_EMPHASISMARK, "CharEmphasis", 0 )
+
+ IPM_MAP_ENTRY( EE_PARA_WRITINGDIR, "WritingMode", 0 )
+
+ IPM_MAP_ENTRY( EE_PARA_ASIANCJKSPACING, "ParaIsCharacterDistance", 0 )
+ );
+
+ return aCharacterPropertyMap;
+}
+} // anonymous namespace
+
+// ========================================
+
+namespace chart
+{
+namespace wrapper
+{
+
+CharacterPropertyItemConverter::CharacterPropertyItemConverter(
+ const uno::Reference< beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool ) :
+ ItemConverter( rPropertySet, rItemPool )
+{}
+
+CharacterPropertyItemConverter::CharacterPropertyItemConverter(
+ const uno::Reference< beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool,
+ ::std::auto_ptr< awt::Size > pRefSize,
+ const ::rtl::OUString & rRefSizePropertyName,
+ const uno::Reference< beans::XPropertySet > & rRefSizePropSet ) :
+ ItemConverter( rPropertySet, rItemPool ),
+ m_pRefSize( pRefSize ),
+ m_aRefSizePropertyName( rRefSizePropertyName ),
+ m_xRefSizePropSet( rRefSizePropSet.is() ? rRefSizePropSet : rPropertySet )
+{}
+
+CharacterPropertyItemConverter::~CharacterPropertyItemConverter()
+{}
+
+const sal_uInt16 * CharacterPropertyItemConverter::GetWhichPairs() const
+{
+ return nCharacterPropertyWhichPairs;
+}
+
+bool CharacterPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
+{
+ ::comphelper::ItemPropertyMapType & rMap( lcl_GetCharacterPropertyPropertyMap());
+ ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
+
+ if( aIt == rMap.end())
+ return false;
+
+ rOutProperty =(*aIt).second;
+ return true;
+}
+
+void CharacterPropertyItemConverter::FillSpecialItem(
+ sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+ throw( uno::Exception )
+{
+ switch( nWhichId )
+ {
+ case EE_CHAR_FONTINFO:
+ case EE_CHAR_FONTINFO_CJK:
+ case EE_CHAR_FONTINFO_CTL:
+ {
+ ::rtl::OUString aPostfix;
+ if( nWhichId == EE_CHAR_FONTINFO_CJK )
+ aPostfix = C2U( "Asian" );
+ else if( nWhichId == EE_CHAR_FONTINFO_CTL )
+ aPostfix = C2U( "Complex" );
+
+ SvxFontItem aItem( nWhichId );
+
+ aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "CharFontName" ) + aPostfix),
+ MID_FONT_FAMILY_NAME );
+ aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "CharFontFamily" ) + aPostfix),
+ MID_FONT_FAMILY );
+ aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "CharFontStyleName" ) + aPostfix),
+ MID_FONT_STYLE_NAME );
+ aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "CharFontCharSet" ) + aPostfix),
+ MID_FONT_CHAR_SET );
+ aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "CharFontPitch" ) + aPostfix),
+ MID_FONT_PITCH );
+
+ rOutItemSet.Put( aItem );
+ }
+ break;
+
+ case EE_CHAR_UNDERLINE:
+ {
+ SvxUnderlineItem aItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE);
+ bool bModified = false;
+
+ uno::Any aValue( GetPropertySet()->getPropertyValue( C2U( "CharUnderline" )));
+ if( aValue.hasValue())
+ {
+ aItem.PutValue( aValue, MID_TL_STYLE );
+ bModified = true;
+ }
+
+ aValue = GetPropertySet()->getPropertyValue( C2U( "CharUnderlineHasColor" ));
+ if( aValue.hasValue() &&
+ ( *reinterpret_cast< const sal_Bool * >( aValue.getValue()) != sal_False ))
+ {
+ aItem.PutValue( aValue, MID_TL_HASCOLOR );
+ bModified = true;
+ }
+
+ aValue = GetPropertySet()->getPropertyValue( C2U( "CharUnderlineColor" ));
+ if( aValue.hasValue())
+ {
+ aItem.PutValue( aValue, MID_TL_COLOR );
+ bModified = true;
+ }
+
+ if( bModified )
+ rOutItemSet.Put( aItem );
+ }
+ break;
+
+ case EE_CHAR_OVERLINE:
+ {
+ SvxOverlineItem aItem( UNDERLINE_NONE, EE_CHAR_OVERLINE );
+ bool bModified = false;
+
+ uno::Any aValue( GetPropertySet()->getPropertyValue( C2U( "CharOverline" ) ) );
+ if ( aValue.hasValue() )
+ {
+ aItem.PutValue( aValue, MID_TL_STYLE );
+ bModified = true;
+ }
+
+ aValue = GetPropertySet()->getPropertyValue( C2U( "CharOverlineHasColor" ) );
+ if ( aValue.hasValue() &&
+ ( *reinterpret_cast< const sal_Bool* >( aValue.getValue() ) != sal_False ) )
+ {
+ aItem.PutValue( aValue, MID_TL_HASCOLOR );
+ bModified = true;
+ }
+
+ aValue = GetPropertySet()->getPropertyValue( C2U( "CharOverlineColor" ) );
+ if ( aValue.hasValue() )
+ {
+ aItem.PutValue( aValue, MID_TL_COLOR );
+ bModified = true;
+ }
+
+ if ( bModified )
+ {
+ rOutItemSet.Put( aItem );
+ }
+ }
+ break;
+
+ case EE_CHAR_ITALIC:
+ case EE_CHAR_ITALIC_CJK:
+ case EE_CHAR_ITALIC_CTL:
+ {
+ ::rtl::OUString aPostfix;
+ if( nWhichId == EE_CHAR_ITALIC_CJK )
+ aPostfix = C2U( "Asian" );
+ else if( nWhichId == EE_CHAR_ITALIC_CTL )
+ aPostfix = C2U( "Complex" );
+
+ SvxPostureItem aItem( ITALIC_NONE, nWhichId );
+
+ uno::Any aValue( GetPropertySet()->getPropertyValue( C2U( "CharPosture" ) + aPostfix));
+ if( aValue.hasValue())
+ {
+ aItem.PutValue( aValue, MID_POSTURE );
+ rOutItemSet.Put( aItem );
+ }
+ }
+ break;
+
+ case EE_CHAR_WEIGHT:
+ case EE_CHAR_WEIGHT_CJK:
+ case EE_CHAR_WEIGHT_CTL:
+ {
+ ::rtl::OUString aPostfix;
+ if( nWhichId == EE_CHAR_WEIGHT_CJK )
+ aPostfix = C2U( "Asian" );
+ else if( nWhichId == EE_CHAR_WEIGHT_CTL )
+ aPostfix = C2U( "Complex" );
+
+ SvxWeightItem aItem( WEIGHT_NORMAL, nWhichId );
+
+ uno::Any aValue( GetPropertySet()->getPropertyValue( C2U( "CharWeight" ) + aPostfix));
+ if( aValue.hasValue())
+ {
+ aItem.PutValue( aValue, MID_WEIGHT );
+ rOutItemSet.Put( aItem );
+ }
+ }
+ break;
+
+ case EE_CHAR_FONTHEIGHT:
+ case EE_CHAR_FONTHEIGHT_CJK:
+ case EE_CHAR_FONTHEIGHT_CTL:
+ {
+ ::rtl::OUString aPostfix;
+ if( nWhichId == EE_CHAR_FONTHEIGHT_CJK )
+ aPostfix = C2U( "Asian" );
+ else if( nWhichId == EE_CHAR_FONTHEIGHT_CTL )
+ aPostfix = C2U( "Complex" );
+
+ SvxFontHeightItem aItem( 240, 100, nWhichId );
+
+ try
+ {
+ uno::Any aValue( GetPropertySet()->getPropertyValue( C2U( "CharHeight" ) + aPostfix ));
+ float fHeight;
+ if( aValue >>= fHeight )
+ {
+ if( m_pRefSize.get())
+ {
+ awt::Size aOldRefSize;
+ if( GetRefSizePropertySet()->getPropertyValue( m_aRefSizePropertyName ) >>= aOldRefSize )
+ {
+ // calculate font height in view
+ fHeight = static_cast< float >(
+ RelativeSizeHelper::calculate( fHeight, aOldRefSize, *m_pRefSize ));
+ aValue <<= fHeight;
+ }
+ }
+
+ aItem.PutValue( aValue, MID_FONTHEIGHT );
+ rOutItemSet.Put( aItem );
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+ break;
+
+ case SID_CHAR_DLG_PREVIEW_STRING:
+ {
+ uno::Reference< chart2::XFormattedString > xFormattedString( GetPropertySet(), uno::UNO_QUERY );
+ if( xFormattedString.is() )
+ {
+ ::rtl::OUString aString = xFormattedString->getString();
+ rOutItemSet.Put( SfxStringItem( nWhichId, aString ) );
+ }
+ else
+ rOutItemSet.Put( SfxStringItem( nWhichId, C2U( "" ) ) );
+ }
+ break;
+
+ case EE_PARA_FORBIDDENRULES:
+ case EE_PARA_HANGINGPUNCTUATION:
+ rOutItemSet.DisableItem( nWhichId );
+ break;
+ }
+}
+
+bool CharacterPropertyItemConverter::ApplySpecialItem(
+ sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
+ throw( uno::Exception )
+{
+ bool bChanged = false;
+ uno::Any aValue;
+
+ switch( nWhichId )
+ {
+ case EE_CHAR_FONTINFO:
+ case EE_CHAR_FONTINFO_CJK:
+ case EE_CHAR_FONTINFO_CTL:
+ {
+ ::rtl::OUString aPostfix;
+ if( nWhichId == EE_CHAR_FONTINFO_CJK )
+ aPostfix = C2U( "Asian" );
+ else if( nWhichId == EE_CHAR_FONTINFO_CTL )
+ aPostfix = C2U( "Complex" );
+
+ const SvxFontItem & rItem =
+ static_cast< const SvxFontItem & >(
+ rItemSet.Get( nWhichId ));
+
+ if( rItem.QueryValue( aValue, MID_FONT_FAMILY_NAME ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharFontName" ) + aPostfix ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharFontName" ) + aPostfix, aValue );
+ bChanged = true;
+ }
+ }
+ if( rItem.QueryValue( aValue, MID_FONT_FAMILY ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharFontFamily" ) + aPostfix ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharFontFamily" ) + aPostfix, aValue );
+ bChanged = true;
+ }
+ }
+ if( rItem.QueryValue( aValue, MID_FONT_STYLE_NAME ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharFontStyleName" ) + aPostfix ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharFontStyleName" ) + aPostfix, aValue );
+ bChanged = true;
+ }
+ }
+ if( rItem.QueryValue( aValue, MID_FONT_CHAR_SET ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharFontCharSet" ) + aPostfix ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharFontCharSet" ) + aPostfix, aValue );
+ bChanged = true;
+ }
+ }
+ if( rItem.QueryValue( aValue, MID_FONT_PITCH ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharFontPitch" ) + aPostfix ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharFontPitch" ) + aPostfix, aValue );
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case EE_CHAR_UNDERLINE:
+ {
+ const SvxUnderlineItem & rItem =
+ static_cast< const SvxUnderlineItem & >(
+ rItemSet.Get( nWhichId ));
+
+ if( rItem.QueryValue( aValue, MID_TL_STYLE ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharUnderline" ) ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharUnderline" ), aValue );
+ bChanged = true;
+ }
+ }
+
+ if( rItem.QueryValue( aValue, MID_TL_COLOR ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharUnderlineColor" ) ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharUnderlineColor" ), aValue );
+ bChanged = true;
+ }
+ }
+
+ if( rItem.QueryValue( aValue, MID_TL_HASCOLOR ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharUnderlineHasColor" ) ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharUnderlineHasColor" ), aValue );
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case EE_CHAR_OVERLINE:
+ {
+ const SvxOverlineItem& rItem = static_cast< const SvxOverlineItem & >( rItemSet.Get( nWhichId ) );
+
+ if ( rItem.QueryValue( aValue, MID_TL_STYLE ) )
+ {
+ if ( aValue != GetPropertySet()->getPropertyValue( C2U( "CharOverline" ) ) )
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharOverline" ), aValue );
+ bChanged = true;
+ }
+ }
+
+ if ( rItem.QueryValue( aValue, MID_TL_COLOR ) )
+ {
+ if ( aValue != GetPropertySet()->getPropertyValue( C2U( "CharOverlineColor" ) ) )
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharOverlineColor" ), aValue );
+ bChanged = true;
+ }
+ }
+
+ if ( rItem.QueryValue( aValue, MID_TL_HASCOLOR ) )
+ {
+ if ( aValue != GetPropertySet()->getPropertyValue( C2U( "CharOverlineHasColor" ) ) )
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharOverlineHasColor" ), aValue );
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case EE_CHAR_ITALIC:
+ case EE_CHAR_ITALIC_CJK:
+ case EE_CHAR_ITALIC_CTL:
+ {
+ ::rtl::OUString aPostfix;
+ if( nWhichId == EE_CHAR_ITALIC_CJK )
+ aPostfix = C2U( "Asian" );
+ else if( nWhichId == EE_CHAR_ITALIC_CTL )
+ aPostfix = C2U( "Complex" );
+
+ const SvxPostureItem & rItem =
+ static_cast< const SvxPostureItem & >(
+ rItemSet.Get( nWhichId ));
+
+ if( rItem.QueryValue( aValue, MID_POSTURE ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharPosture" ) + aPostfix))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharPosture" ) + aPostfix, aValue );
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case EE_CHAR_WEIGHT:
+ case EE_CHAR_WEIGHT_CJK:
+ case EE_CHAR_WEIGHT_CTL:
+ {
+ ::rtl::OUString aPostfix;
+ if( nWhichId == EE_CHAR_WEIGHT_CJK )
+ aPostfix = C2U( "Asian" );
+ else if( nWhichId == EE_CHAR_WEIGHT_CTL )
+ aPostfix = C2U( "Complex" );
+
+ const SvxWeightItem & rItem =
+ static_cast< const SvxWeightItem & >(
+ rItemSet.Get( nWhichId ));
+
+ if( rItem.QueryValue( aValue, MID_WEIGHT ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharWeight" ) + aPostfix))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "CharWeight" ) + aPostfix, aValue );
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case EE_CHAR_FONTHEIGHT:
+ case EE_CHAR_FONTHEIGHT_CJK:
+ case EE_CHAR_FONTHEIGHT_CTL:
+ {
+ ::rtl::OUString aPostfix;
+ if( nWhichId == EE_CHAR_FONTHEIGHT_CJK )
+ aPostfix = C2U( "Asian" );
+ else if( nWhichId == EE_CHAR_FONTHEIGHT_CTL )
+ aPostfix = C2U( "Complex" );
+
+ const SvxFontHeightItem & rItem =
+ static_cast< const SvxFontHeightItem & >(
+ rItemSet.Get( nWhichId ));
+
+ try
+ {
+ if( rItem.QueryValue( aValue, MID_FONTHEIGHT ) )
+ {
+ bool bSetValue = false;
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharHeight" ) + aPostfix ))
+ bSetValue = true;
+ else
+ {
+ if( m_pRefSize.get() )
+ {
+ awt::Size aNewRefSize = *m_pRefSize;
+ awt::Size aOldRefSize;
+ if( GetRefSizePropertySet()->getPropertyValue( m_aRefSizePropertyName ) >>= aOldRefSize )
+ {
+ if( aNewRefSize.Width != aOldRefSize.Width
+ || aNewRefSize.Height != aOldRefSize.Height )
+ bSetValue = true;
+ }
+ }
+ }
+ if( bSetValue )
+ {
+ // set new reference size only if there was a reference size before (auto-scaling on)
+ if( m_pRefSize.get() &&
+ GetRefSizePropertySet()->getPropertyValue( m_aRefSizePropertyName ).hasValue())
+ {
+ GetRefSizePropertySet()->setPropertyValue( m_aRefSizePropertyName,
+ uno::makeAny( *m_pRefSize ));
+ }
+
+ GetPropertySet()->setPropertyValue( C2U( "CharHeight" ) + aPostfix, aValue );
+ bChanged = true;
+ }
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+ break;
+ }
+
+ return bChanged;
+}
+
+uno::Reference< beans::XPropertySet >
+ CharacterPropertyItemConverter::GetRefSizePropertySet() const
+{
+ return m_xRefSizePropSet;
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
new file mode 100644
index 000000000000..e399e4ba82b1
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -0,0 +1,702 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+#include "DataPointItemConverter.hxx"
+#include "SchWhichPairs.hxx"
+#include "macros.hxx"
+#include "ItemPropertyMap.hxx"
+
+#include "GraphicPropertyItemConverter.hxx"
+#include "CharacterPropertyItemConverter.hxx"
+#include "StatisticsItemConverter.hxx"
+#include "SeriesOptionsItemConverter.hxx"
+#include "DataSeriesHelper.hxx"
+#include "DiagramHelper.hxx"
+#include "ChartModelHelper.hxx"
+#include "ChartTypeHelper.hxx"
+#include <svx/chrtitem.hxx>
+#include <com/sun/star/chart2/DataPointLabel.hpp>
+#include <com/sun/star/chart2/Symbol.hpp>
+
+// header for class XFillColorItem
+#include <svx/xflclit.hxx>
+#include <svl/intitem.hxx>
+#include <editeng/sizeitem.hxx>
+// header for class SfxStringItem
+#include <svl/stritem.hxx>
+#include <editeng/brshitem.hxx>
+//SfxIntegerListItem
+#include <svl/ilstitem.hxx>
+#define _SVSTDARR_ULONGS
+#include <svl/svstdarr.hxx>
+#include <vcl/graph.hxx>
+#include <com/sun/star/graphic/XGraphic.hpp>
+
+// for SVX_SYMBOLTYPE_...
+#include <svx/tabline.hxx>
+
+#include <functional>
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+using ::com::sun::star::uno::Reference;
+
+namespace
+{
+::comphelper::ItemPropertyMapType & lcl_GetDataPointPropertyMap()
+{
+ static ::comphelper::ItemPropertyMapType aDataPointPropertyMap(
+ ::comphelper::MakeItemPropertyMap
+ IPM_MAP_ENTRY( SCHATTR_STYLE_SHAPE, "Geometry3D", 0 )
+ );
+
+ return aDataPointPropertyMap;
+};
+
+sal_Int32 lcl_getSymbolStyleForSymbol( const chart2::Symbol & rSymbol )
+{
+ sal_Int32 nStyle = SVX_SYMBOLTYPE_UNKNOWN;
+ switch( rSymbol.Style )
+ {
+ case chart2::SymbolStyle_NONE:
+ nStyle = SVX_SYMBOLTYPE_NONE;
+ break;
+ case chart2::SymbolStyle_AUTO:
+ nStyle = SVX_SYMBOLTYPE_AUTO;
+ break;
+ case chart2::SymbolStyle_GRAPHIC:
+ nStyle = SVX_SYMBOLTYPE_BRUSHITEM;
+ break;
+ case chart2::SymbolStyle_STANDARD:
+ nStyle = rSymbol.StandardSymbol;
+ break;
+
+ case chart2::SymbolStyle_POLYGON:
+ // to avoid warning
+ case chart2::SymbolStyle_MAKE_FIXED_SIZE:
+ // nothing
+ break;
+ }
+ return nStyle;
+}
+
+bool lcl_NumberFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso )
+{
+ bool bChanged = false;
+ if( !xPropertySet.is() )
+ return bChanged;
+ rtl::OUString aPropertyName = (SID_ATTR_NUMBERFORMAT_VALUE==nWhichId) ? C2U( "NumberFormat" ) : C2U( "PercentageNumberFormat" );
+ sal_uInt16 nSourceWhich = (SID_ATTR_NUMBERFORMAT_VALUE==nWhichId) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE;
+
+ if( SFX_ITEM_SET != rItemSet.GetItemState( nSourceWhich ) )
+ return bChanged;
+
+ uno::Any aValue;
+ bool bUseSourceFormat = (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nSourceWhich )).GetValue() );
+ if( !bUseSourceFormat )
+ {
+ SfxItemState aState = rItemSet.GetItemState( nWhichId );
+ if( aState == SFX_ITEM_SET )
+ {
+ sal_Int32 nFmt = static_cast< sal_Int32 >(
+ static_cast< const SfxUInt32Item & >(
+ rItemSet.Get( nWhichId )).GetValue());
+ aValue = uno::makeAny(nFmt);
+ }
+ else
+ return bChanged;
+ }
+
+ uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
+ if( bOverwriteAttributedDataPointsAlso )
+ {
+ Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY);
+ if( aValue != aOldValue ||
+ ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
+ {
+ ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aValue );
+ bChanged = true;
+ }
+ }
+ else if( aOldValue != aValue )
+ {
+ xPropertySet->setPropertyValue(aPropertyName, aValue );
+ bChanged = true;
+ }
+ return bChanged;
+}
+
+bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso )
+{
+ bool bChanged = false;
+ if( !xPropertySet.is() )
+ return bChanged;
+ rtl::OUString aPropertyName = (SID_ATTR_NUMBERFORMAT_SOURCE==nWhichId) ? C2U( "NumberFormat" ) : C2U( "PercentageNumberFormat" );
+ sal_uInt16 nFormatWhich = (SID_ATTR_NUMBERFORMAT_SOURCE==nWhichId) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE;
+
+ if( SFX_ITEM_SET != rItemSet.GetItemState( nWhichId ) )
+ return bChanged;
+
+ uno::Any aNewValue;
+ bool bUseSourceFormat = (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue() );
+ if( !bUseSourceFormat )
+ {
+ SfxItemState aState = rItemSet.GetItemState( nFormatWhich );
+ if( aState == SFX_ITEM_SET )
+ {
+ sal_Int32 nFormatKey = static_cast< sal_Int32 >(
+ static_cast< const SfxUInt32Item & >(
+ rItemSet.Get( nFormatWhich )).GetValue());
+ aNewValue <<= nFormatKey;
+ }
+ else
+ return bChanged;
+ }
+
+ uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) );
+ if( bOverwriteAttributedDataPointsAlso )
+ {
+ Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY);
+ if( aNewValue != aOldValue ||
+ ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) )
+ {
+ ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aNewValue );
+ bChanged = true;
+ }
+ }
+ else if( aOldValue != aNewValue )
+ {
+ xPropertySet->setPropertyValue( aPropertyName, aNewValue );
+ bChanged = true;
+ }
+
+ return bChanged;
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+namespace wrapper
+{
+
+DataPointItemConverter::DataPointItemConverter(
+ const uno::Reference< frame::XModel > & xChartModel,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ const uno::Reference< beans::XPropertySet > & rPropertySet,
+ const uno::Reference< XDataSeries > & xSeries,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ NumberFormatterWrapper * pNumFormatter,
+ const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
+ GraphicPropertyItemConverter::eGraphicObjectType eMapTo /* = FILL_PROPERTIES */,
+ ::std::auto_ptr< awt::Size > pRefSize /* = NULL */,
+ bool bDataSeries /* = false */,
+ bool bUseSpecialFillColor /* = false */,
+ sal_Int32 nSpecialFillColor /* =0 */,
+ bool bOverwriteLabelsForAttributedDataPointsAlso /*false*/,
+ sal_Int32 nNumberFormat,
+ sal_Int32 nPercentNumberFormat
+ ) :
+ ItemConverter( rPropertySet, rItemPool ),
+ m_pNumberFormatterWrapper( pNumFormatter ),
+ m_bDataSeries( bDataSeries ),
+ m_bOverwriteLabelsForAttributedDataPointsAlso(m_bDataSeries && bOverwriteLabelsForAttributedDataPointsAlso),
+ m_bUseSpecialFillColor(bUseSpecialFillColor),
+ m_nSpecialFillColor(nSpecialFillColor),
+ m_nNumberFormat(nNumberFormat),
+ m_nPercentNumberFormat(nPercentNumberFormat),
+ m_aAvailableLabelPlacements(),
+ m_bForbidPercentValue(true)
+{
+ m_aConverters.push_back( new GraphicPropertyItemConverter(
+ rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, eMapTo ));
+ m_aConverters.push_back( new CharacterPropertyItemConverter( rPropertySet, rItemPool, pRefSize,
+ C2U( "ReferencePageSize" )));
+ if( bDataSeries )
+ {
+ m_aConverters.push_back( new StatisticsItemConverter( xChartModel, rPropertySet, rItemPool ));
+ m_aConverters.push_back( new SeriesOptionsItemConverter( xChartModel, xContext, rPropertySet, rItemPool ));
+ }
+
+ uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) );
+ uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xSeries ) );
+ bool bFound = false;
+ bool bAmbiguous = false;
+ sal_Bool bSwapXAndY = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
+ m_aAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements( xChartType, DiagramHelper::getDimension( xDiagram ), bSwapXAndY, xSeries );
+
+ m_bForbidPercentValue = AxisType::CATEGORY != ChartTypeHelper::getAxisType( xChartType, 0 );
+}
+
+DataPointItemConverter::~DataPointItemConverter()
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::DeleteItemConverterPtr() );
+}
+
+void DataPointItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::FillItemSetFunc( rOutItemSet ));
+
+ // own items
+ ItemConverter::FillItemSet( rOutItemSet );
+
+ if( m_bUseSpecialFillColor )
+ {
+ Color aColor(m_nSpecialFillColor);
+ rOutItemSet.Put( XFillColorItem( String(), aColor ) );
+ }
+}
+
+bool DataPointItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
+{
+ bool bResult = false;
+
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::ApplyItemSetFunc( rItemSet, bResult ));
+
+ // own items
+ return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
+}
+
+const sal_uInt16 * DataPointItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ if( m_bDataSeries )
+ return nRowWhichPairs;
+ return nDataPointWhichPairs;
+}
+
+bool DataPointItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
+{
+ ::comphelper::ItemPropertyMapType & rMap( lcl_GetDataPointPropertyMap());
+ ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
+
+ if( aIt == rMap.end())
+ return false;
+
+ rOutProperty =(*aIt).second;
+ return true;
+}
+
+
+bool DataPointItemConverter::ApplySpecialItem(
+ sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
+ throw( uno::Exception )
+{
+ bool bChanged = false;
+ uno::Any aValue;
+
+ switch( nWhichId )
+ {
+ case SCHATTR_DATADESCR_SHOW_NUMBER:
+ case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
+ case SCHATTR_DATADESCR_SHOW_CATEGORY:
+ case SCHATTR_DATADESCR_SHOW_SYMBOL:
+ {
+ const SfxBoolItem & rItem = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId ));
+
+ uno::Any aOldValue( GetPropertySet()->getPropertyValue( C2U( "Label" ) ));
+ chart2::DataPointLabel aLabel;
+ if( aOldValue >>= aLabel )
+ {
+ sal_Bool& rValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : (
+ (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : (
+ (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
+ sal_Bool bOldValue = rValue;
+ rValue = static_cast< sal_Bool >( rItem.GetValue() );
+ if( m_bOverwriteLabelsForAttributedDataPointsAlso )
+ {
+ Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
+ if( bOldValue != rValue ||
+ DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "Label" ), aOldValue ) )
+ {
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "Label" ), uno::makeAny( aLabel ) );
+ bChanged = true;
+ }
+ }
+ else if( bOldValue != rValue )
+ {
+ GetPropertySet()->setPropertyValue( C2U( "Label" ), uno::makeAny( aLabel ));
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case SID_ATTR_NUMBERFORMAT_VALUE:
+ case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: //fall through intended
+ {
+ bChanged = lcl_NumberFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
+ }
+ break;
+
+ case SID_ATTR_NUMBERFORMAT_SOURCE:
+ case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: //fall through intended
+ {
+ bChanged = lcl_UseSourceFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso );
+ }
+ break;
+
+ case SCHATTR_DATADESCR_SEPARATOR:
+ {
+ rtl::OUString aNewValue = static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue();
+ rtl::OUString aOldValue;
+ try
+ {
+ GetPropertySet()->getPropertyValue( C2U( "LabelSeparator" ) ) >>= aOldValue;
+ if( m_bOverwriteLabelsForAttributedDataPointsAlso )
+ {
+ Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
+ if( !aOldValue.equals(aNewValue) ||
+ DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "LabelSeparator" ), uno::makeAny( aOldValue ) ) )
+ {
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "LabelSeparator" ), uno::makeAny( aNewValue ) );
+ bChanged = true;
+ }
+ }
+ else if( !aOldValue.equals(aNewValue) )
+ {
+ GetPropertySet()->setPropertyValue( C2U( "LabelSeparator" ), uno::makeAny( aNewValue ));
+ bChanged = true;
+ }
+ }
+ catch( uno::Exception& e )
+ {
+ ASSERT_EXCEPTION( e );
+ }
+ }
+ break;
+
+ case SCHATTR_DATADESCR_PLACEMENT:
+ {
+
+ try
+ {
+ sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
+ sal_Int32 nOld =0;
+ if( !(GetPropertySet()->getPropertyValue( C2U( "LabelPlacement" ) ) >>= nOld) )
+ {
+ if( m_aAvailableLabelPlacements.getLength() )
+ nOld = m_aAvailableLabelPlacements[0];
+ }
+ if( m_bOverwriteLabelsForAttributedDataPointsAlso )
+ {
+ Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY);
+ if( nOld!=nNew ||
+ DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "LabelPlacement" ), uno::makeAny( nOld ) ) )
+ {
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "LabelPlacement" ), uno::makeAny( nNew ) );
+ bChanged = true;
+ }
+ }
+ else if( nOld!=nNew )
+ {
+ GetPropertySet()->setPropertyValue( C2U( "LabelPlacement" ), uno::makeAny( nNew ));
+ bChanged = true;
+ }
+ }
+ catch( uno::Exception& e )
+ {
+ ASSERT_EXCEPTION( e );
+ }
+ }
+ break;
+
+ case SCHATTR_STYLE_SYMBOL:
+ {
+ sal_Int32 nStyle =
+ static_cast< const SfxInt32Item & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ chart2::Symbol aSymbol;
+
+ GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol;
+ sal_Int32 nOldStyle = lcl_getSymbolStyleForSymbol( aSymbol );
+
+ if( nStyle != nOldStyle )
+ {
+ bool bDeleteSymbol = false;
+ switch( nStyle )
+ {
+ case SVX_SYMBOLTYPE_NONE:
+ aSymbol.Style = chart2::SymbolStyle_NONE;
+ break;
+ case SVX_SYMBOLTYPE_AUTO:
+ aSymbol.Style = chart2::SymbolStyle_AUTO;
+ break;
+ case SVX_SYMBOLTYPE_BRUSHITEM:
+ aSymbol.Style = chart2::SymbolStyle_GRAPHIC;
+ break;
+ case SVX_SYMBOLTYPE_UNKNOWN:
+ bDeleteSymbol = true;
+ break;
+
+ default:
+ aSymbol.Style = chart2::SymbolStyle_STANDARD;
+ aSymbol.StandardSymbol = nStyle;
+ }
+
+ if( bDeleteSymbol )
+ GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::Any());
+ else
+ GetPropertySet()->setPropertyValue( C2U( "Symbol" ),
+ uno::makeAny( aSymbol ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_SYMBOL_SIZE:
+ {
+ Size aSize = static_cast< const SvxSizeItem & >(
+ rItemSet.Get( nWhichId )).GetSize();
+ chart2::Symbol aSymbol;
+
+ GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol;
+ if( aSize.getWidth() != aSymbol.Size.Width ||
+ aSize.getHeight() != aSymbol.Size.Height )
+ {
+ aSymbol.Size.Width = aSize.getWidth();
+ aSymbol.Size.Height = aSize.getHeight();
+
+ GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::makeAny( aSymbol ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_SYMBOL_BRUSH:
+ {
+ const SvxBrushItem & rBrshItem( static_cast< const SvxBrushItem & >(
+ rItemSet.Get( nWhichId )));
+ uno::Any aXGraphicAny;
+ const Graphic *pGraphic( rBrshItem.GetGraphic());
+ if( pGraphic )
+ {
+ uno::Reference< graphic::XGraphic > xGraphic( pGraphic->GetXGraphic());
+ if( xGraphic.is())
+ {
+ aXGraphicAny <<= xGraphic;
+ chart2::Symbol aSymbol;
+ GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol;
+ if( aSymbol.Graphic != xGraphic )
+ {
+ aSymbol.Graphic = xGraphic;
+ GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::makeAny( aSymbol ));
+ bChanged = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_TEXT_DEGREES:
+ {
+ double fValue = static_cast< double >(
+ static_cast< const SfxInt32Item & >(
+ rItemSet.Get( nWhichId )).GetValue()) / 100.0;
+ double fOldValue = 0.0;
+ bool bPropExisted =
+ ( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fOldValue );
+
+ if( ! bPropExisted ||
+ ( bPropExisted && fOldValue != fValue ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "TextRotation" ), uno::makeAny( fValue ));
+ bChanged = true;
+ }
+ }
+ break;
+ }
+
+ return bChanged;
+}
+
+void DataPointItemConverter::FillSpecialItem(
+ sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+ throw( uno::Exception )
+{
+ switch( nWhichId )
+ {
+ case SCHATTR_DATADESCR_SHOW_NUMBER:
+ case SCHATTR_DATADESCR_SHOW_PERCENTAGE:
+ case SCHATTR_DATADESCR_SHOW_CATEGORY:
+ case SCHATTR_DATADESCR_SHOW_SYMBOL:
+ {
+ chart2::DataPointLabel aLabel;
+ if( GetPropertySet()->getPropertyValue( C2U( "Label" )) >>= aLabel )
+ {
+ sal_Bool bValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : (
+ (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : (
+ (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol ));
+
+ rOutItemSet.Put( SfxBoolItem( nWhichId, bValue ));
+
+ if( m_bOverwriteLabelsForAttributedDataPointsAlso )
+ {
+ if( DataSeriesHelper::hasAttributedDataPointDifferentValue(
+ Reference< chart2::XDataSeries >( GetPropertySet(), uno::UNO_QUERY), C2U( "Label" ), uno::makeAny(aLabel) ) )
+ {
+ rOutItemSet.InvalidateItem(nWhichId);
+ }
+ }
+ }
+ }
+ break;
+
+ case SID_ATTR_NUMBERFORMAT_VALUE:
+ {
+ sal_Int32 nKey = 0;
+ if( !(GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) >>= nKey) )
+ nKey = m_nNumberFormat;
+ rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
+ }
+ break;
+
+ case SCHATTR_PERCENT_NUMBERFORMAT_VALUE:
+ {
+ sal_Int32 nKey = 0;
+ if( !(GetPropertySet()->getPropertyValue( C2U( "PercentageNumberFormat" )) >>= nKey) )
+ nKey = m_nPercentNumberFormat;
+ rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey ));
+ }
+ break;
+
+ case SID_ATTR_NUMBERFORMAT_SOURCE:
+ {
+ bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )).hasValue());
+ rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
+ }
+ break;
+ case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
+ {
+ bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "PercentageNumberFormat" )).hasValue());
+ rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
+ }
+ break;
+
+ case SCHATTR_DATADESCR_SEPARATOR:
+ {
+ rtl::OUString aValue;
+ try
+ {
+ GetPropertySet()->getPropertyValue( C2U( "LabelSeparator" ) ) >>= aValue;
+ rOutItemSet.Put( SfxStringItem( nWhichId, aValue ));
+ }
+ catch( uno::Exception& e )
+ {
+ ASSERT_EXCEPTION( e );
+ }
+ }
+ break;
+
+ case SCHATTR_DATADESCR_PLACEMENT:
+ {
+ try
+ {
+ sal_Int32 nPlacement=0;
+ if( GetPropertySet()->getPropertyValue( C2U( "LabelPlacement" ) ) >>= nPlacement )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, nPlacement ));
+ else if( m_aAvailableLabelPlacements.getLength() )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, m_aAvailableLabelPlacements[0] ));
+ }
+ catch( uno::Exception& e )
+ {
+ ASSERT_EXCEPTION( e );
+ }
+ }
+ break;
+
+ case SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS:
+ {
+ SvULongs aList;
+ for ( sal_Int32 nN=0; nN<m_aAvailableLabelPlacements.getLength(); nN++ )
+ aList.Insert( m_aAvailableLabelPlacements[nN], sal::static_int_cast< sal_uInt16 >(nN) );
+ rOutItemSet.Put( SfxIntegerListItem( nWhichId, aList ) );
+ }
+ break;
+
+ case SCHATTR_DATADESCR_NO_PERCENTVALUE:
+ {
+ rOutItemSet.Put( SfxBoolItem( nWhichId, m_bForbidPercentValue ));
+ }
+ break;
+
+ case SCHATTR_STYLE_SYMBOL:
+ {
+ chart2::Symbol aSymbol;
+ if( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, lcl_getSymbolStyleForSymbol( aSymbol ) ));
+ }
+ break;
+
+ case SCHATTR_SYMBOL_SIZE:
+ {
+ chart2::Symbol aSymbol;
+ if( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol )
+ rOutItemSet.Put(
+ SvxSizeItem( nWhichId, Size( aSymbol.Size.Width, aSymbol.Size.Height ) ));
+ }
+ break;
+
+ case SCHATTR_SYMBOL_BRUSH:
+ {
+ chart2::Symbol aSymbol;
+ if(( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol )
+ && aSymbol.Graphic.is() )
+ {
+ rOutItemSet.Put( SvxBrushItem( Graphic( aSymbol.Graphic ), GPOS_MM, SCHATTR_SYMBOL_BRUSH ));
+ }
+ }
+ break;
+
+ case SCHATTR_TEXT_DEGREES:
+ {
+ double fValue = 0;
+
+ if( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fValue )
+ {
+ rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >(
+ ::rtl::math::round( fValue * 100.0 ) ) ));
+ }
+ }
+ break;
+ }
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx
new file mode 100644
index 000000000000..3304f36f9e42
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx
@@ -0,0 +1,459 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+#include "ErrorBarItemConverter.hxx"
+#include "SchWhichPairs.hxx"
+#include "macros.hxx"
+#include "ItemPropertyMap.hxx"
+#include "ErrorBar.hxx"
+#include "PropertyHelper.hxx"
+#include "ChartModelHelper.hxx"
+#include "ChartTypeHelper.hxx"
+#include "StatisticsHelper.hxx"
+
+#include "GraphicPropertyItemConverter.hxx"
+
+#include <svl/stritem.hxx>
+#include <svx/chrtitem.hxx>
+#include <svl/intitem.hxx>
+#include <rtl/math.hxx>
+
+#include <com/sun/star/chart2/DataPointLabel.hpp>
+#include <com/sun/star/chart2/XInternalDataProvider.hpp>
+#include <com/sun/star/chart/ErrorBarStyle.hpp>
+#include <com/sun/star/lang/XServiceName.hpp>
+
+#include <functional>
+#include <algorithm>
+#include <vector>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+
+void lcl_getErrorValues( const uno::Reference< beans::XPropertySet > & xErrorBarProp,
+ double & rOutPosError, double & rOutNegError )
+{
+ if( ! xErrorBarProp.is())
+ return;
+
+ try
+ {
+ xErrorBarProp->getPropertyValue( C2U( "PositiveError" )) >>= rOutPosError;
+ xErrorBarProp->getPropertyValue( C2U( "NegativeError" )) >>= rOutNegError;
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+}
+
+void lcl_getErrorIndicatorValues(
+ const uno::Reference< beans::XPropertySet > & xErrorBarProp,
+ bool & rOutShowPosError, bool & rOutShowNegError )
+{
+ if( ! xErrorBarProp.is())
+ return;
+
+ try
+ {
+ xErrorBarProp->getPropertyValue( C2U( "ShowPositiveError" )) >>= rOutShowPosError;
+ xErrorBarProp->getPropertyValue( C2U( "ShowNegativeError" )) >>= rOutShowNegError;
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+namespace wrapper
+{
+
+ErrorBarItemConverter::ErrorBarItemConverter(
+ const uno::Reference< frame::XModel > & xModel,
+ const uno::Reference< beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) :
+ ItemConverter( rPropertySet, rItemPool ),
+ m_spGraphicConverter( new GraphicPropertyItemConverter(
+ rPropertySet, rItemPool, rDrawModel,
+ xNamedPropertyContainerFactory,
+ GraphicPropertyItemConverter::LINE_PROPERTIES )),
+ m_xModel( xModel )
+{}
+
+ErrorBarItemConverter::~ErrorBarItemConverter()
+{}
+
+void ErrorBarItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
+{
+ m_spGraphicConverter->FillItemSet( rOutItemSet );
+
+ // own items
+ ItemConverter::FillItemSet( rOutItemSet );
+}
+
+bool ErrorBarItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
+{
+ bool bResult = m_spGraphicConverter->ApplyItemSet( rItemSet );
+
+ // own items
+ return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
+}
+
+const sal_uInt16 * ErrorBarItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nErrorBarWhichPairs;
+}
+
+bool ErrorBarItemConverter::GetItemProperty(
+ tWhichIdType /* nWhichId */,
+ tPropertyNameWithMemberId & /* rOutProperty */ ) const
+{
+ return false;
+}
+
+bool ErrorBarItemConverter::ApplySpecialItem(
+ sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
+ throw( uno::Exception )
+{
+ bool bChanged = false;
+ uno::Any aValue;
+
+ switch( nWhichId )
+ {
+ // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT,
+ // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS,
+ // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE
+ case SCHATTR_STAT_KIND_ERROR:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet());
+
+ SvxChartKindError eErrorKind =
+ static_cast< const SvxChartKindErrorItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+
+ if( !xErrorBarProp.is() && eErrorKind == CHERROR_NONE)
+ {
+ //nothing to do
+ }
+ else
+ {
+ sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
+
+ switch( eErrorKind )
+ {
+ case CHERROR_NONE:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; break;
+ case CHERROR_VARIANT:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::VARIANCE; break;
+ case CHERROR_SIGMA:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION; break;
+ case CHERROR_PERCENT:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE; break;
+ case CHERROR_BIGERROR:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN; break;
+ case CHERROR_CONST:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE; break;
+ case CHERROR_STDERROR:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR; break;
+ case CHERROR_RANGE:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::FROM_DATA; break;
+ }
+
+ xErrorBarProp->setPropertyValue( C2U( "ErrorBarStyle" ),
+ uno::makeAny( nStyle ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_PERCENT:
+ case SCHATTR_STAT_BIGERROR:
+ {
+ OSL_FAIL( "Deprectaed item" );
+ uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet());
+
+ double fValue =
+ static_cast< const SvxDoubleItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ double fPos, fNeg;
+ lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
+
+ if( ! ( ::rtl::math::approxEqual( fPos, fValue ) &&
+ ::rtl::math::approxEqual( fNeg, fValue )))
+ {
+ xErrorBarProp->setPropertyValue( C2U( "PositiveError" ),
+ uno::makeAny( fValue ));
+ xErrorBarProp->setPropertyValue( C2U( "NegativeError" ),
+ uno::makeAny( fValue ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_CONSTPLUS:
+ {
+ double fValue =
+ static_cast< const SvxDoubleItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ double fPos, fNeg;
+ lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
+
+ if( ! ::rtl::math::approxEqual( fPos, fValue ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "PositiveError" ), uno::makeAny( fValue ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_CONSTMINUS:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet());
+
+ double fValue =
+ static_cast< const SvxDoubleItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ double fPos, fNeg;
+ lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
+
+ if( ! ::rtl::math::approxEqual( fNeg, fValue ))
+ {
+ xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), uno::makeAny( fValue ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_INDICATE:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet());
+
+ SvxChartIndicate eIndicate =
+ static_cast< const SvxChartIndicateItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+
+ bool bNewIndPos = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_UP );
+ bool bNewIndNeg = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_DOWN );
+
+ bool bShowPos, bShowNeg;
+ lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg );
+
+ if( ( bShowPos != bNewIndPos ||
+ bShowNeg != bNewIndNeg ))
+ {
+ xErrorBarProp->setPropertyValue( C2U( "ShowPositiveError" ), uno::makeAny( bNewIndPos ));
+ xErrorBarProp->setPropertyValue( C2U( "ShowNegativeError" ), uno::makeAny( bNewIndNeg ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_RANGE_POS:
+ case SCHATTR_STAT_RANGE_NEG:
+ {
+ // @todo: also be able to deal with x-error bars
+ const bool bYError = true;
+ uno::Reference< chart2::data::XDataSource > xErrorBarSource( GetPropertySet(), uno::UNO_QUERY );
+ uno::Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY );
+ uno::Reference< chart2::data::XDataProvider > xDataProvider;
+
+ if( xChartDoc.is())
+ xDataProvider.set( xChartDoc->getDataProvider());
+ if( xErrorBarSource.is() && xDataProvider.is())
+ {
+ ::rtl::OUString aNewRange( static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue());
+ bool bApplyNewRange = false;
+
+ bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS );
+ if( xChartDoc->hasInternalDataProvider())
+ {
+ if( aNewRange.getLength())
+ {
+ uno::Reference< chart2::data::XDataSequence > xSeq(
+ StatisticsHelper::getErrorDataSequenceFromDataSource(
+ xErrorBarSource, bIsPositiveValue, bYError ));
+ if( ! xSeq.is())
+ {
+ // no data range for error bars yet => create
+ uno::Reference< chart2::XInternalDataProvider > xIntDataProvider( xDataProvider, uno::UNO_QUERY );
+ OSL_ASSERT( xIntDataProvider.is());
+ if( xIntDataProvider.is())
+ {
+ xIntDataProvider->appendSequence();
+ aNewRange = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("last"));
+ bApplyNewRange = true;
+ }
+ }
+ }
+ }
+ else
+ {
+ uno::Reference< chart2::data::XDataSequence > xSeq(
+ StatisticsHelper::getErrorDataSequenceFromDataSource(
+ xErrorBarSource, bIsPositiveValue, bYError ));
+ bApplyNewRange =
+ ! ( xSeq.is() && aNewRange.equals( xSeq->getSourceRangeRepresentation()));
+ }
+
+ if( bApplyNewRange )
+ StatisticsHelper::setErrorDataSequence(
+ xErrorBarSource, xDataProvider, aNewRange, bIsPositiveValue, bYError );
+ }
+ }
+ break;
+ }
+
+ return bChanged;
+}
+
+void ErrorBarItemConverter::FillSpecialItem(
+ sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+ throw( uno::Exception )
+{
+ switch( nWhichId )
+ {
+ case SCHATTR_STAT_KIND_ERROR:
+ {
+ SvxChartKindError eErrorKind = CHERROR_NONE;
+ uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet());
+
+ sal_Int32 nStyle = 0;
+ if( xErrorBarProp->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nStyle )
+ {
+ switch( nStyle )
+ {
+ case ::com::sun::star::chart::ErrorBarStyle::NONE:
+ break;
+ case ::com::sun::star::chart::ErrorBarStyle::VARIANCE:
+ eErrorKind = CHERROR_VARIANT; break;
+ case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION:
+ eErrorKind = CHERROR_SIGMA; break;
+ case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE:
+ eErrorKind = CHERROR_CONST; break;
+ case ::com::sun::star::chart::ErrorBarStyle::RELATIVE:
+ eErrorKind = CHERROR_PERCENT; break;
+ case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN:
+ eErrorKind = CHERROR_BIGERROR; break;
+ case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR:
+ eErrorKind = CHERROR_STDERROR; break;
+ case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA:
+ eErrorKind = CHERROR_RANGE; break;
+ }
+ }
+ rOutItemSet.Put( SvxChartKindErrorItem( eErrorKind, SCHATTR_STAT_KIND_ERROR ));
+ }
+ break;
+
+ case SCHATTR_STAT_PERCENT:
+ {
+ double fPos, fNeg;
+ lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
+ rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
+ }
+ break;
+
+ case SCHATTR_STAT_BIGERROR:
+ {
+ double fPos, fNeg;
+ lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
+ rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
+ }
+ break;
+
+ case SCHATTR_STAT_CONSTPLUS:
+ {
+ double fPos, fNeg;
+ lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
+ rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId ));
+ }
+ break;
+
+ case SCHATTR_STAT_CONSTMINUS:
+ {
+ double fPos, fNeg;
+ lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
+ rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId ));
+ }
+ break;
+
+ case SCHATTR_STAT_INDICATE:
+ {
+ SvxChartIndicate eIndicate = CHINDICATE_BOTH;
+ bool bShowPos, bShowNeg;
+ lcl_getErrorIndicatorValues( GetPropertySet(), bShowPos, bShowNeg );
+
+ if( bShowPos )
+ {
+ if( bShowNeg )
+ eIndicate = CHINDICATE_BOTH;
+ else
+ eIndicate = CHINDICATE_UP;
+ }
+ else
+ {
+ if( bShowNeg )
+ eIndicate = CHINDICATE_DOWN;
+ else
+ eIndicate = CHINDICATE_NONE;
+ }
+ rOutItemSet.Put( SvxChartIndicateItem( eIndicate, SCHATTR_STAT_INDICATE ));
+ }
+ break;
+
+ case SCHATTR_STAT_RANGE_POS:
+ case SCHATTR_STAT_RANGE_NEG:
+ {
+ uno::Reference< chart2::data::XDataSource > xErrorBarSource( GetPropertySet(), uno::UNO_QUERY );
+ if( xErrorBarSource.is())
+ {
+ uno::Reference< chart2::data::XDataSequence > xSeq(
+ StatisticsHelper::getErrorDataSequenceFromDataSource(
+ xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS) /*, true */ /* y */ ));
+ if( xSeq.is())
+ rOutItemSet.Put( SfxStringItem( nWhichId, String( xSeq->getSourceRangeRepresentation())));
+ }
+ }
+ break;
+ }
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx
new file mode 100644
index 000000000000..05b8af1c4ba6
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx
@@ -0,0 +1,794 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+#include "GraphicPropertyItemConverter.hxx"
+#include "SchWhichPairs.hxx"
+#include "macros.hxx"
+#include "ItemPropertyMap.hxx"
+#include "PropertyHelper.hxx"
+#include "CommonConverters.hxx"
+#include <editeng/memberids.hrc>
+#include <svx/xflclit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xflbmtit.hxx>
+#include <svx/xflbstit.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xflftrit.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xflgrit.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/xlntrit.hxx>
+#include <editeng/eeitem.hxx>
+// for SfxBoolItem
+#include <svl/eitem.hxx>
+// for XFillGradientStepCountItem
+#include <svx/xgrscit.hxx>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/chart2/FillBitmap.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+::comphelper::ItemPropertyMapType & lcl_GetDataPointFilledPropertyMap()
+{
+ static ::comphelper::ItemPropertyMapType aDataPointPropertyFilledMap(
+ ::comphelper::MakeItemPropertyMap
+ IPM_MAP_ENTRY( XATTR_FILLSTYLE, "FillStyle", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLCOLOR, "Color", 0 )
+ IPM_MAP_ENTRY( XATTR_LINECOLOR, "BorderColor", 0 )
+ IPM_MAP_ENTRY( XATTR_LINESTYLE, "BorderStyle", 0 )
+ IPM_MAP_ENTRY( XATTR_LINEWIDTH, "BorderWidth", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBACKGROUND, "FillBackground", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_POS, "FillBitmapRectanglePoint", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX, "FillBitmapSizeX", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY, "FillBitmapSizeY", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG, "FillBitmapLogicalSize", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX, "FillBitmapOffsetX", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY, "FillBitmapOffsetY", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX, "FillBitmapPositionOffsetX", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY, "FillBitmapPositionOffsetY", 0 )
+ );
+
+ return aDataPointPropertyFilledMap;
+}
+::comphelper::ItemPropertyMapType & lcl_GetDataPointLinePropertyMap()
+{
+ static ::comphelper::ItemPropertyMapType aDataPointPropertyLineMap(
+ ::comphelper::MakeItemPropertyMap
+ IPM_MAP_ENTRY( XATTR_LINECOLOR, "Color", 0 )
+ IPM_MAP_ENTRY( XATTR_LINESTYLE, "LineStyle", 0 )
+ IPM_MAP_ENTRY( XATTR_LINEWIDTH, "LineWidth", 0 )
+ );
+
+ return aDataPointPropertyLineMap;
+}
+::comphelper::ItemPropertyMapType & lcl_GetLinePropertyMap()
+{
+ static ::comphelper::ItemPropertyMapType aLinePropertyMap(
+ ::comphelper::MakeItemPropertyMap
+ IPM_MAP_ENTRY( XATTR_LINESTYLE, "LineStyle", 0 )
+ IPM_MAP_ENTRY( XATTR_LINEWIDTH, "LineWidth", 0 )
+ IPM_MAP_ENTRY( XATTR_LINECOLOR, "LineColor", 0 )
+ IPM_MAP_ENTRY( XATTR_LINEJOINT, "LineJoint", 0 )
+ );
+
+ return aLinePropertyMap;
+}
+::comphelper::ItemPropertyMapType & lcl_GetFillPropertyMap()
+{
+ static ::comphelper::ItemPropertyMapType aFillPropertyMap(
+ ::comphelper::MakeItemPropertyMap
+ IPM_MAP_ENTRY( XATTR_FILLSTYLE, "FillStyle", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLCOLOR, "FillColor", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBACKGROUND, "FillBackground", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_POS, "FillBitmapRectanglePoint", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX, "FillBitmapSizeX", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY, "FillBitmapSizeY", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG, "FillBitmapLogicalSize", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX, "FillBitmapOffsetX", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY, "FillBitmapOffsetY", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX, "FillBitmapPositionOffsetX", 0 )
+ IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY, "FillBitmapPositionOffsetY", 0 )
+ );
+
+ return aFillPropertyMap;
+}
+
+bool lcl_supportsFillProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType )
+{
+ return ( eType == ::chart::wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT ||
+ eType == ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES ||
+ eType == ::chart::wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES );
+}
+
+bool lcl_supportsLineProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType )
+{
+ return ( eType != ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES );
+}
+
+bool lcl_SetContentForNamedProperty(
+ const uno::Reference< lang::XMultiServiceFactory > & xFactory,
+ const ::rtl::OUString & rTableName,
+ NameOrIndex & rItem, sal_uInt8 nMemberId )
+{
+ bool bResult = false;
+ if( xFactory.is())
+ {
+ ::rtl::OUString aPropertyValue( rItem.GetName());
+ uno::Reference< container::XNameAccess > xNameAcc(
+ xFactory->createInstance( rTableName ),
+ uno::UNO_QUERY );
+ if( xNameAcc.is() &&
+ xNameAcc->hasByName( aPropertyValue ))
+ {
+ rItem.PutValue( xNameAcc->getByName( aPropertyValue ), nMemberId );
+ bResult = true;
+ }
+ }
+ return bResult;
+}
+
+} // anonymous namespace
+
+// ========================================
+
+namespace chart
+{
+namespace wrapper
+{
+
+GraphicPropertyItemConverter::GraphicPropertyItemConverter(
+ const uno::Reference<
+ beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
+ eGraphicObjectType eObjectType /* = FILL_PROPERTIES */ ) :
+ ItemConverter( rPropertySet, rItemPool ),
+ m_eGraphicObjectType( eObjectType ),
+ m_rDrawModel( rDrawModel ),
+ m_xNamedPropertyTableFactory( xNamedPropertyContainerFactory )
+{}
+
+GraphicPropertyItemConverter::~GraphicPropertyItemConverter()
+{}
+
+const sal_uInt16 * GraphicPropertyItemConverter::GetWhichPairs() const
+{
+ const sal_uInt16 * pResult = NULL;
+
+ switch( m_eGraphicObjectType )
+ {
+ case LINE_DATA_POINT:
+ case FILLED_DATA_POINT:
+ pResult = nRowWhichPairs; break;
+ case LINE_PROPERTIES:
+ pResult = nLinePropertyWhichPairs; break;
+ case FILL_PROPERTIES:
+ pResult = nFillPropertyWhichPairs; break;
+ case LINE_AND_FILL_PROPERTIES:
+ pResult = nLineAndFillPropertyWhichPairs; break;
+ }
+
+ return pResult;
+}
+
+bool GraphicPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
+{
+ ::comphelper::ItemPropertyMapType::const_iterator aEndIt;
+ ::comphelper::ItemPropertyMapType::const_iterator aIt;
+
+ switch( m_eGraphicObjectType )
+ {
+ case LINE_DATA_POINT:
+ aEndIt = lcl_GetDataPointLinePropertyMap().end();
+ aIt = lcl_GetDataPointLinePropertyMap().find( nWhichId );
+ break;
+ case FILLED_DATA_POINT:
+ aEndIt = lcl_GetDataPointFilledPropertyMap().end();
+ aIt = lcl_GetDataPointFilledPropertyMap().find( nWhichId );
+ break;
+ case LINE_PROPERTIES:
+ aEndIt = lcl_GetLinePropertyMap().end();
+ aIt = lcl_GetLinePropertyMap().find( nWhichId );
+ break;
+
+ case FILL_PROPERTIES:
+ aEndIt = lcl_GetFillPropertyMap().end();
+ aIt = lcl_GetFillPropertyMap().find( nWhichId );
+ break;
+
+ case LINE_AND_FILL_PROPERTIES:
+ // line
+ aEndIt = lcl_GetLinePropertyMap().end();
+ aIt = lcl_GetLinePropertyMap().find( nWhichId );
+
+ // not found => try fill
+ if( aIt == aEndIt )
+ {
+ aEndIt = lcl_GetFillPropertyMap().end();
+ aIt = lcl_GetFillPropertyMap().find( nWhichId );
+ }
+ break;
+ }
+
+ if( aIt == aEndIt )
+ return false;
+
+ rOutProperty =(*aIt).second;
+ return true;
+}
+
+void GraphicPropertyItemConverter::FillSpecialItem(
+ sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+ throw( uno::Exception )
+{
+ switch( nWhichId )
+ {
+ // bitmap property
+ case XATTR_FILLBMP_TILE:
+ case XATTR_FILLBMP_STRETCH:
+ {
+ drawing::BitmapMode aMode = drawing::BitmapMode_REPEAT;
+ if( GetPropertySet()->getPropertyValue( C2U("FillBitmapMode")) >>= aMode )
+ {
+ rOutItemSet.Put( XFillBmpTileItem( aMode == drawing::BitmapMode_REPEAT ));
+ rOutItemSet.Put( XFillBmpStretchItem( aMode == drawing::BitmapMode_STRETCH ));
+ }
+ }
+ break;
+
+ case XATTR_FILLFLOATTRANSPARENCE:
+ try
+ {
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "TransparencyGradientName" )
+ : C2U( "FillTransparenceGradientName" );
+
+ uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ));
+ if( aValue.hasValue())
+ {
+ XFillFloatTransparenceItem aItem;
+ aItem.PutValue( aValue, MID_NAME );
+
+ lcl_SetContentForNamedProperty(
+ m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.TransparencyGradientTable"),
+ aItem, MID_FILLGRADIENT );
+
+ // this is important to enable the item
+ ::rtl::OUString aName;
+ if( (aValue >>= aName) &&
+ aName.getLength())
+ {
+ aItem.SetEnabled( sal_True );
+ rOutItemSet.Put( aItem );
+ }
+ }
+ }
+ }
+ catch( beans::UnknownPropertyException &ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ break;
+
+ case XATTR_GRADIENTSTEPCOUNT:
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "GradientStepCount" )
+ : C2U( "FillGradientStepCount" );
+
+ uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ) );
+ if( hasLongOrShortValue(aValue) )
+ {
+ sal_Int16 nStepCount = getShortForLongAlso(aValue);
+ rOutItemSet.Put( XGradientStepCountItem( nStepCount ));
+ }
+ }
+ break;
+
+ case XATTR_LINEDASH:
+ if( lcl_supportsLineProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "BorderDashName" )
+ : C2U( "LineDashName" );
+
+ XLineDashItem aItem;
+ aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
+
+ lcl_SetContentForNamedProperty(
+ m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.DashTable"),
+ aItem, MID_LINEDASH );
+
+ // translate model name to UI-name for predefined entries, so
+ // that the correct entry is chosen in the list of UI-names
+ XLineDashItem * pItemToPut = & aItem;
+ pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
+
+ rOutItemSet.Put( * pItemToPut );
+ }
+ break;
+
+ case XATTR_FILLGRADIENT:
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "GradientName" )
+ : C2U( "FillGradientName" );
+
+ XFillGradientItem aItem;
+ aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
+
+ lcl_SetContentForNamedProperty(
+ m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.GradientTable"),
+ aItem, MID_FILLGRADIENT );
+
+ // translate model name to UI-name for predefined entries, so
+ // that the correct entry is chosen in the list of UI-names
+ XFillGradientItem * pItemToPut = & aItem;
+ pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
+
+ rOutItemSet.Put( * pItemToPut );
+ }
+ break;
+
+ case XATTR_FILLHATCH:
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "HatchName" )
+ : C2U( "FillHatchName" );
+
+ XFillHatchItem aItem;
+ aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
+
+ lcl_SetContentForNamedProperty(
+ m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.HatchTable"),
+ aItem, MID_FILLHATCH );
+
+ // translate model name to UI-name for predefined entries, so
+ // that the correct entry is chosen in the list of UI-names
+ XFillHatchItem * pItemToPut = & aItem;
+ pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
+
+ rOutItemSet.Put( * pItemToPut );
+ }
+ break;
+
+ case XATTR_FILLBITMAP:
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ XFillBitmapItem aItem;
+ aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" ) ), MID_NAME );
+
+ lcl_SetContentForNamedProperty(
+ m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.BitmapTable"),
+ aItem, MID_GRAFURL );
+
+ // translate model name to UI-name for predefined entries, so
+ // that the correct entry is chosen in the list of UI-names
+ XFillBitmapItem * pItemToPut = & aItem;
+ pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
+
+ rOutItemSet.Put( * pItemToPut );
+ }
+ break;
+
+ // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
+ // instead of sal_Int16
+ case XATTR_LINETRANSPARENCE:
+ if( lcl_supportsLineProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "BorderTransparency" )
+ : (m_eGraphicObjectType == LINE_DATA_POINT)
+ ? C2U( "Transparency" )
+ : C2U( "LineTransparence" );
+
+ XLineTransparenceItem aItem;
+ aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) );
+
+ rOutItemSet.Put( aItem );
+ }
+ break;
+
+ // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
+ // instead of sal_Int16
+ case XATTR_FILLTRANSPARENCE:
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "Transparency" )
+ : C2U( "FillTransparence" );
+
+ XFillTransparenceItem aItem;
+ aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) );
+
+ rOutItemSet.Put( aItem );
+ }
+ break;
+ }
+}
+
+bool GraphicPropertyItemConverter::ApplySpecialItem(
+ sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
+ throw( uno::Exception )
+{
+ bool bChanged = false;
+ uno::Any aValue;
+
+ switch( nWhichId )
+ {
+ // bitmap property
+ case XATTR_FILLBMP_STRETCH:
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ const ::rtl::OUString aModePropName = C2U("FillBitmapMode");
+ bool bStretched = static_cast< const XFillBmpStretchItem & >(
+ rItemSet.Get( XATTR_FILLBMP_STRETCH )).GetValue();
+ drawing::BitmapMode aMode =
+ (bStretched ? drawing::BitmapMode_STRETCH : drawing::BitmapMode_NO_REPEAT);
+
+ aValue <<= aMode;
+ if( aValue != GetPropertySet()->getPropertyValue( aModePropName ))
+ {
+ GetPropertySet()->setPropertyValue( aModePropName, aValue );
+ bChanged = true;
+ }
+ }
+ break;
+
+ case XATTR_FILLBMP_TILE:
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ const ::rtl::OUString aModePropName = C2U("FillBitmapMode");
+ bool bTiled = static_cast< const XFillBmpTileItem & >(
+ rItemSet.Get( XATTR_FILLBMP_TILE )).GetValue();
+ drawing::BitmapMode aMode =
+ (bTiled ? drawing::BitmapMode_REPEAT : drawing::BitmapMode_NO_REPEAT);
+
+ aValue <<= aMode;
+ if( aValue != GetPropertySet()->getPropertyValue( aModePropName ))
+ {
+ GetPropertySet()->setPropertyValue( aModePropName, aValue );
+ bChanged = true;
+ }
+ }
+ break;
+
+ case XATTR_FILLFLOATTRANSPARENCE:
+ try
+ {
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "TransparencyGradientName" )
+ : C2U( "FillTransparenceGradientName" );
+
+ const XFillFloatTransparenceItem & rItem =
+ static_cast< const XFillFloatTransparenceItem & >(
+ rItemSet.Get( nWhichId ));
+
+ if( rItem.IsEnabled() &&
+ rItem.QueryValue( aValue, MID_NAME ))
+ {
+ uno::Any aGradient;
+ rItem.QueryValue( aGradient, MID_FILLGRADIENT );
+
+ // add TransparencyGradient to list if it does not already exist
+ ::rtl::OUString aPreferredName;
+ aValue >>= aPreferredName;
+ aValue <<= PropertyHelper::addTransparencyGradientUniqueNameToTable(
+ aGradient, m_xNamedPropertyTableFactory, aPreferredName );
+
+ if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
+ {
+ GetPropertySet()->setPropertyValue( aPropName, aValue );
+ bChanged = true;
+ }
+ }
+ else
+ {
+ ::rtl::OUString aName;
+ if( ( GetPropertySet()->getPropertyValue( aPropName ) >>= aName )
+ && aName.getLength() > 0 )
+ {
+ uno::Reference< beans::XPropertyState > xState( GetPropertySet(), uno::UNO_QUERY );
+ if( xState.is())
+ xState->setPropertyToDefault( aPropName );
+ bChanged = true;
+ }
+ }
+ }
+ }
+ catch( beans::UnknownPropertyException &ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ break;
+
+ case XATTR_GRADIENTSTEPCOUNT:
+ {
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "GradientStepCount" )
+ : C2U( "FillGradientStepCount" );
+
+ sal_Int16 nStepCount = ( static_cast< const XGradientStepCountItem & >(
+ rItemSet.Get( nWhichId ))).GetValue();
+
+ aValue <<= nStepCount;
+ if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
+ {
+ GetPropertySet()->setPropertyValue( aPropName, aValue );
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case XATTR_LINEDASH:
+ {
+ if( lcl_supportsLineProperties( m_eGraphicObjectType ))
+ {
+
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "BorderDashName" )
+ : C2U( "LineDashName" );
+
+ const XLineDashItem & rItem =
+ static_cast< const XLineDashItem & >(
+ rItemSet.Get( nWhichId ));
+
+ if( rItem.QueryValue( aValue, MID_NAME ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
+ {
+ // add LineDash to list
+ uno::Any aLineDash;
+ rItem.QueryValue( aLineDash, MID_LINEDASH );
+ ::rtl::OUString aPreferredName;
+ aValue >>= aPreferredName;
+ aValue <<= PropertyHelper::addLineDashUniqueNameToTable(
+ aLineDash, m_xNamedPropertyTableFactory, aPreferredName );
+
+ GetPropertySet()->setPropertyValue( aPropName, aValue );
+ bChanged = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case XATTR_FILLGRADIENT:
+ {
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "GradientName" )
+ : C2U( "FillGradientName" );
+
+ const XFillGradientItem & rItem =
+ static_cast< const XFillGradientItem & >(
+ rItemSet.Get( nWhichId ));
+
+ if( rItem.QueryValue( aValue, MID_NAME ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
+ {
+ // add Gradient to list
+ uno::Any aGradient;
+ rItem.QueryValue( aGradient, MID_FILLGRADIENT );
+ ::rtl::OUString aPreferredName;
+ aValue >>= aPreferredName;
+ aValue <<= PropertyHelper::addGradientUniqueNameToTable(
+ aGradient, m_xNamedPropertyTableFactory, aPreferredName );
+
+ GetPropertySet()->setPropertyValue( aPropName, aValue );
+ bChanged = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case XATTR_FILLHATCH:
+ {
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "HatchName" )
+ : C2U( "FillHatchName" );
+
+ const XFillHatchItem & rItem =
+ static_cast< const XFillHatchItem & >(
+ rItemSet.Get( nWhichId ));
+
+ if( rItem.QueryValue( aValue, MID_NAME ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
+ {
+ // add Hatch to list
+ uno::Any aHatch;
+ rItem.QueryValue( aHatch, MID_FILLHATCH );
+ ::rtl::OUString aPreferredName;
+ aValue >>= aPreferredName;
+ aValue <<= PropertyHelper::addHatchUniqueNameToTable(
+ aHatch, m_xNamedPropertyTableFactory, aPreferredName );
+
+ GetPropertySet()->setPropertyValue( aPropName, aValue );
+ bChanged = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case XATTR_FILLBITMAP:
+ {
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ const XFillBitmapItem & rItem =
+ static_cast< const XFillBitmapItem & >(
+ rItemSet.Get( nWhichId ));
+
+ if( rItem.QueryValue( aValue, MID_NAME ))
+ {
+ if( aValue != GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" )))
+ {
+ // add Bitmap to list
+ uno::Any aBitmap;
+ rItem.QueryValue( aBitmap, MID_GRAFURL );
+ ::rtl::OUString aPreferredName;
+ aValue >>= aPreferredName;
+ aValue <<= PropertyHelper::addBitmapUniqueNameToTable(
+ aBitmap, m_xNamedPropertyTableFactory, aPreferredName );
+
+ GetPropertySet()->setPropertyValue( C2U( "FillBitmapName" ), aValue );
+ bChanged = true;
+ }
+ }
+ }
+ }
+ break;
+
+ // hack, because QueryValue of XLineTransparenceItem returns sal_Int32
+ // instead of sal_Int16
+ case XATTR_LINETRANSPARENCE:
+ if( lcl_supportsLineProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "BorderTransparency" )
+ : (m_eGraphicObjectType == LINE_DATA_POINT)
+ ? C2U( "Transparency" )
+ : C2U( "LineTransparence" );
+
+ const XLineTransparenceItem & rItem =
+ static_cast< const XLineTransparenceItem & >(
+ rItemSet.Get( nWhichId ));
+
+ if( rItem.QueryValue( aValue ))
+ {
+ OSL_ENSURE( ! aValue.isExtractableTo(
+ ::getCppuType( reinterpret_cast< const sal_Int16 * >(0))),
+ "TransparenceItem QueryValue bug is fixed. Remove hack." );
+ sal_Int32 nValue = 0;
+ if( aValue >>= nValue )
+ {
+ OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" );
+ sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue ));
+ aValue <<= nValueToSet;
+
+ GetPropertySet()->setPropertyValue( aPropName, aValue );
+ bChanged = true;
+ }
+ else
+ {
+ OSL_FAIL( "Wrong type in Transparency Any" );
+ }
+ }
+ }
+ break;
+
+ // hack, because QueryValue of XFillTransparenceItem returns sal_Int32
+ // instead of sal_Int16
+ case XATTR_FILLTRANSPARENCE:
+ if( lcl_supportsFillProperties( m_eGraphicObjectType ))
+ {
+ ::rtl::OUString aPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "Transparency" )
+ : C2U( "FillTransparence" );
+
+ const XFillTransparenceItem & rItem =
+ static_cast< const XFillTransparenceItem & >(
+ rItemSet.Get( nWhichId ));
+
+ if( rItem.QueryValue( aValue ))
+ {
+ OSL_ENSURE( ! aValue.isExtractableTo(
+ ::getCppuType( reinterpret_cast< const sal_Int16 * >(0))),
+ "TransparenceItem QueryValue bug is fixed. Remove hack." );
+ sal_Int32 nValue = 0;
+ if( aValue >>= nValue )
+ {
+ OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" );
+ sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue ));
+ aValue <<= nValueToSet;
+
+ GetPropertySet()->setPropertyValue( aPropName, aValue );
+ // if linear or no transparence is set, delete the gradient
+ ::rtl::OUString aTransGradPropName =
+ (m_eGraphicObjectType == FILLED_DATA_POINT)
+ ? C2U( "TransparencyGradientName" )
+ : C2U( "FillTransparenceGradientName" );
+ GetPropertySet()->setPropertyValue(
+ aTransGradPropName, uno::makeAny( ::rtl::OUString() ));
+
+ bChanged = true;
+ }
+ else
+ {
+ OSL_FAIL( "Wrong type in Transparency Any" );
+ }
+ }
+ }
+ break;
+ }
+
+ return bChanged;
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
new file mode 100644
index 000000000000..a121a774615c
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
@@ -0,0 +1,270 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+#include "ItemConverter.hxx"
+#include "macros.hxx"
+#include <com/sun/star/lang/XComponent.hpp>
+#include <svl/itemprop.hxx>
+#include <svl/itemiter.hxx>
+// header for class SfxWhichIter
+#include <svl/whiter.hxx>
+#include <svx/svxids.hrc>
+
+using namespace ::com::sun::star;
+
+namespace comphelper
+{
+
+ItemConverter::ItemConverter(
+ const uno::Reference< beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool ) :
+ m_xPropertySet( rPropertySet ),
+ m_xPropertySetInfo( NULL ),
+ m_rItemPool( rItemPool ),
+ m_bIsValid( true )
+{
+ resetPropertySet( m_xPropertySet );
+}
+
+ItemConverter::~ItemConverter()
+{
+ stopAllComponentListening();
+}
+
+void ItemConverter::resetPropertySet(
+ const uno::Reference< beans::XPropertySet > & xPropSet )
+{
+ if( xPropSet.is())
+ {
+ stopAllComponentListening();
+ m_xPropertySet = xPropSet;
+ m_xPropertySetInfo = m_xPropertySet->getPropertySetInfo();
+
+ uno::Reference< lang::XComponent > xComp( m_xPropertySet, uno::UNO_QUERY );
+ if( xComp.is())
+ {
+ // method of base class ::utl::OEventListenerAdapter
+ startComponentListening( xComp );
+ }
+ }
+}
+
+SfxItemPool & ItemConverter::GetItemPool() const
+{
+ return m_rItemPool;
+}
+
+SfxItemSet ItemConverter::CreateEmptyItemSet() const
+{
+ return SfxItemSet( GetItemPool(), GetWhichPairs() );
+}
+
+uno::Reference< beans::XPropertySet > ItemConverter::GetPropertySet() const
+{
+ return m_xPropertySet;
+}
+
+void ItemConverter::_disposing( const lang::EventObject& rSource )
+{
+ if( rSource.Source == m_xPropertySet )
+ {
+ m_bIsValid = false;
+ }
+}
+
+void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
+{
+ const sal_uInt16 * pRanges = rOutItemSet.GetRanges();
+ tPropertyNameWithMemberId aProperty;
+ SfxItemPool & rPool = GetItemPool();
+
+ OSL_ASSERT( pRanges != NULL );
+ OSL_ASSERT( m_xPropertySetInfo.is());
+ OSL_ASSERT( m_xPropertySet.is());
+
+ while( (*pRanges) != 0)
+ {
+ sal_uInt16 nBeg = (*pRanges);
+ ++pRanges;
+ sal_uInt16 nEnd = (*pRanges);
+ ++pRanges;
+
+ OSL_ASSERT( nBeg <= nEnd );
+ for( sal_uInt16 nWhich = nBeg; nWhich <= nEnd; ++nWhich )
+ {
+ if( GetItemProperty( nWhich, aProperty ))
+ {
+ // put the Property into the itemset
+ SfxPoolItem * pItem = rPool.GetDefaultItem( nWhich ).Clone();
+
+ if( pItem )
+ {
+ try
+ {
+ if( ! pItem->PutValue( m_xPropertySet->getPropertyValue( aProperty.first ),
+ aProperty.second // nMemberId
+ ))
+ {
+ delete pItem;
+ }
+ else
+ {
+ rOutItemSet.Put( *pItem, nWhich );
+ delete pItem;
+ }
+ }
+ catch( beans::UnknownPropertyException &ex )
+ {
+ delete pItem;
+ OSL_FAIL(
+ ::rtl::OUStringToOString(
+ ex.Message +
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ " - unknown Property: " )) + aProperty.first,
+ RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+ catch( uno::Exception &ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+ }
+ else
+ {
+ try
+ {
+ FillSpecialItem( nWhich, rOutItemSet );
+ }
+ catch( uno::Exception &ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+ }
+ }
+}
+
+void ItemConverter::FillSpecialItem(
+ sal_uInt16 /*nWhichId*/, SfxItemSet & /*rOutItemSet*/ ) const
+ throw( uno::Exception )
+{
+ OSL_FAIL( "ItemConverter: Unhandled special item found!" );
+}
+
+bool ItemConverter::ApplySpecialItem(
+ sal_uInt16 /*nWhichId*/, const SfxItemSet & /*rItemSet*/ )
+ throw( uno::Exception )
+{
+ OSL_FAIL( "ItemConverter: Unhandled special item found!" );
+ return false;
+}
+
+bool ItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
+{
+ OSL_ASSERT( m_xPropertySet.is());
+
+ bool bItemsChanged = false;
+ SfxItemIter aIter( rItemSet );
+ const SfxPoolItem * pItem = aIter.FirstItem();
+ tPropertyNameWithMemberId aProperty;
+ uno::Any aValue;
+
+ while( pItem )
+ {
+ if( rItemSet.GetItemState( pItem->Which(), sal_False ) == SFX_ITEM_SET )
+ {
+ if( GetItemProperty( pItem->Which(), aProperty ))
+ {
+ pItem->QueryValue( aValue, aProperty.second /* nMemberId */ );
+
+ try
+ {
+ if( aValue != m_xPropertySet->getPropertyValue( aProperty.first ))
+ {
+ m_xPropertySet->setPropertyValue( aProperty.first, aValue );
+ bItemsChanged = true;
+ }
+ }
+ catch( beans::UnknownPropertyException &ex )
+ {
+ OSL_FAIL(
+ ::rtl::OUStringToOString(
+ ex.Message +
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ " - unknown Property: " )) + aProperty.first,
+ RTL_TEXTENCODING_ASCII_US).getStr());
+ }
+ catch( uno::Exception &ex )
+ {
+ OSL_FAIL( ::rtl::OUStringToOString(
+ ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+ }
+ else
+ {
+ bItemsChanged = ApplySpecialItem( pItem->Which(), rItemSet ) || bItemsChanged;
+ }
+ }
+ pItem = aIter.NextItem();
+ }
+
+ return bItemsChanged;
+}
+
+// --------------------------------------------------------------------------------
+void ItemConverter::InvalidateUnequalItems( SfxItemSet &rDestSet, const SfxItemSet &rSourceSet )
+{
+ SfxWhichIter aIter (rSourceSet);
+ sal_uInt16 nWhich = aIter.FirstWhich ();
+ const SfxPoolItem *pPoolItem = NULL;
+
+ while (nWhich)
+ {
+ if ((rSourceSet.GetItemState(nWhich, sal_True, &pPoolItem) == SFX_ITEM_SET) &&
+ (rDestSet.GetItemState(nWhich, sal_True, &pPoolItem) == SFX_ITEM_SET))
+ {
+ if (rSourceSet.Get(nWhich) != rDestSet.Get(nWhich))
+ {
+ if( SID_CHAR_DLG_PREVIEW_STRING != nWhich )
+ {
+ rDestSet.InvalidateItem(nWhich);
+ }
+ }
+ }
+ else if( rSourceSet.GetItemState(nWhich, sal_True, &pPoolItem) == SFX_ITEM_DONTCARE )
+ rDestSet.InvalidateItem(nWhich);
+
+ nWhich = aIter.NextWhich ();
+ }
+}
+
+} // namespace comphelper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
new file mode 100644
index 000000000000..75f2254c2218
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
@@ -0,0 +1,206 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+#include "LegendItemConverter.hxx"
+#include "SchWhichPairs.hxx"
+#include "macros.hxx"
+#include "ItemPropertyMap.hxx"
+#include "GraphicPropertyItemConverter.hxx"
+#include "CharacterPropertyItemConverter.hxx"
+#include <com/sun/star/chart2/XLegend.hpp>
+#include <com/sun/star/chart2/LegendPosition.hpp>
+#include <com/sun/star/chart/ChartLegendExpansion.hpp>
+
+#include <svl/intitem.hxx>
+#include <svl/eitem.hxx>
+
+#include <functional>
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+namespace chart
+{
+namespace wrapper
+{
+
+LegendItemConverter::LegendItemConverter(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
+ ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize ) :
+ ItemConverter( rPropertySet, rItemPool )
+{
+ m_aConverters.push_back( new GraphicPropertyItemConverter(
+ rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
+ GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ));
+ m_aConverters.push_back( new CharacterPropertyItemConverter(
+ rPropertySet, rItemPool, pRefSize,
+ C2U( "ReferencePageSize" ) ));
+}
+
+LegendItemConverter::~LegendItemConverter()
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::DeleteItemConverterPtr() );
+}
+
+void LegendItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::FillItemSetFunc( rOutItemSet ));
+
+ // own items
+ ItemConverter::FillItemSet( rOutItemSet );
+}
+
+bool LegendItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
+{
+ bool bResult = false;
+
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::ApplyItemSetFunc( rItemSet, bResult ));
+
+ // own items
+ return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
+}
+
+const sal_uInt16 * LegendItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nLegendWhichPairs;
+}
+
+bool LegendItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyNameWithMemberId & /*rOutProperty*/ ) const
+{
+ // No own (non-special) properties
+ return false;
+}
+
+
+bool LegendItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet& rInItemSet )
+ throw( uno::Exception )
+{
+ bool bChanged = false;
+
+ switch( nWhichId )
+ {
+ case SCHATTR_LEGEND_SHOW:
+ {
+ const SfxPoolItem* pPoolItem = NULL;
+ if( rInItemSet.GetItemState( SCHATTR_LEGEND_SHOW, sal_True, &pPoolItem ) == SFX_ITEM_SET )
+ {
+ sal_Bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
+ sal_Bool bWasShown = sal_True;
+ if( ! (GetPropertySet()->getPropertyValue( C2U("Show")) >>= bWasShown) ||
+ ( bWasShown != bShow ))
+ {
+ GetPropertySet()->setPropertyValue( C2U("Show"), uno::makeAny( bShow ));
+ bChanged = true;
+ }
+ }
+
+ }
+ break;
+ case SCHATTR_LEGEND_POS:
+ {
+ const SfxPoolItem* pPoolItem = NULL;
+ if( rInItemSet.GetItemState( SCHATTR_LEGEND_POS, sal_True, &pPoolItem ) == SFX_ITEM_SET )
+ {
+ chart2::LegendPosition eNewPos = static_cast<chart2::LegendPosition>(((const SfxInt32Item*)pPoolItem)->GetValue());
+
+ ::com::sun::star::chart::ChartLegendExpansion eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH;
+ switch( eNewPos )
+ {
+ case chart2::LegendPosition_LINE_START:
+ case chart2::LegendPosition_LINE_END:
+ eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH;
+ break;
+ case chart2::LegendPosition_PAGE_START:
+ case chart2::LegendPosition_PAGE_END:
+ eExpansion = ::com::sun::star::chart::ChartLegendExpansion_WIDE;
+ break;
+ default:
+ break;
+ }
+
+ try
+ {
+ chart2::LegendPosition eOldPos;
+ if( ! ( GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= eOldPos ) ||
+ ( eOldPos != eNewPos ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( eNewPos ));
+ GetPropertySet()->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eExpansion ));
+ GetPropertySet()->setPropertyValue( C2U( "RelativePosition" ), uno::Any());
+ bChanged = true;
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+ }
+ break;
+ }
+
+ return bChanged;
+}
+
+void LegendItemConverter::FillSpecialItem(
+ sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+ throw( uno::Exception )
+{
+ switch( nWhichId )
+ {
+ case SCHATTR_LEGEND_SHOW:
+ {
+ sal_Bool bShow = sal_True;
+ GetPropertySet()->getPropertyValue( C2U( "Show" )) >>= bShow;
+ rOutItemSet.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, bShow) );
+ }
+ break;
+ case SCHATTR_LEGEND_POS:
+ {
+ chart2::LegendPosition eLegendPos( chart2::LegendPosition_LINE_END );
+ GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= eLegendPos;
+ rOutItemSet.Put( SfxInt32Item(SCHATTR_LEGEND_POS, eLegendPos ) );
+ }
+ break;
+ }
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
new file mode 100644
index 000000000000..46d5269793de
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
@@ -0,0 +1,236 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+#include "MultipleChartConverters.hxx"
+
+#include "chartview/ChartSfxItemIds.hxx"
+#include "SchWhichPairs.hxx"
+#include "AxisItemConverter.hxx"
+#include "StatisticsItemConverter.hxx"
+#include "GraphicPropertyItemConverter.hxx"
+#include "DataPointItemConverter.hxx"
+#include "ChartModelHelper.hxx"
+#include "TitleHelper.hxx"
+#include "TitleItemConverter.hxx"
+#include "AxisHelper.hxx"
+#include "chartview/ExplicitValueProvider.hxx"
+#include "DiagramHelper.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace chart
+{
+namespace wrapper
+{
+
+//-----------------------------------------------------------------------------
+
+AllAxisItemConverter::AllAxisItemConverter(
+ const uno::Reference< frame::XModel > & xChartModel,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ const uno::Reference< lang::XMultiServiceFactory > & /*xNamedPropertyContainerFactory*/,
+ ::std::auto_ptr< awt::Size > pRefSize )
+ : MultipleItemConverter( rItemPool )
+{
+ Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
+ Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
+ for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
+ {
+ uno::Reference< beans::XPropertySet > xObjectProperties(aElementList[nA], uno::UNO_QUERY);
+ if( pRefSize.get())
+ m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter(
+ xObjectProperties, rItemPool, rDrawModel,
+ uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0,
+ ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize )) ));
+ else
+ m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter(
+ xObjectProperties, rItemPool, rDrawModel,
+ uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0 ) );
+ }
+}
+
+AllAxisItemConverter::~AllAxisItemConverter()
+{
+}
+
+const sal_uInt16 * AllAxisItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nAllAxisWhichPairs;
+}
+
+//-----------------------------------------------------------------------------
+
+AllGridItemConverter::AllGridItemConverter(
+ const uno::Reference< frame::XModel > & xChartModel,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
+ : MultipleItemConverter( rItemPool )
+{
+ Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
+ Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) );
+ for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
+ {
+ Reference< beans::XPropertySet > xObjectProperties(aElementList[nA]);
+ m_aConverters.push_back( new ::chart::wrapper::GraphicPropertyItemConverter(
+ xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
+ ::chart::wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES ) );
+ }
+}
+
+AllGridItemConverter::~AllGridItemConverter()
+{
+}
+
+const sal_uInt16 * AllGridItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nGridWhichPairs;
+}
+
+//-----------------------------------------------------------------------------
+
+AllDataLabelItemConverter::AllDataLabelItemConverter(
+ const uno::Reference< frame::XModel > & xChartModel,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
+ ::std::auto_ptr< awt::Size > pRefSize )
+ : MultipleItemConverter( rItemPool )
+{
+ ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
+ ::chart::ChartModelHelper::getDataSeries( xChartModel ));
+
+ ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt;
+ for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt )
+ {
+ uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
+ uno::Reference< uno::XComponentContext> xContext(0);//do not need Context for label properties
+
+ sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, *aIt, -1/*nPointIndex*/, ChartModelHelper::findDiagram( xChartModel ) );
+ sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
+ xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY));
+
+ m_aConverters.push_back( new ::chart::wrapper::DataPointItemConverter(
+ xChartModel, xContext,
+ xObjectProperties, *aIt, rItemPool, rDrawModel, NULL,
+ xNamedPropertyContainerFactory,
+ GraphicPropertyItemConverter::FILLED_DATA_POINT,
+ ::std::auto_ptr< awt::Size >( pRefSize.get() ? new awt::Size( *pRefSize ) : 0),
+ true, /*bDataSeries*/
+ false, /*bUseSpecialFillColor*/
+ 0, /*nSpecialFillColor*/
+ true /*bOverwriteLabelsForAttributedDataPointsAlso*/,
+ nNumberFormat, nPercentNumberFormat
+ ));
+ }
+}
+
+AllDataLabelItemConverter::~AllDataLabelItemConverter()
+{
+}
+
+const sal_uInt16 * AllDataLabelItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nDataLabelWhichPairs;
+}
+
+//-----------------------------------------------------------------------------
+
+AllTitleItemConverter::AllTitleItemConverter(
+ const uno::Reference< frame::XModel > & xChartModel,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
+ ::std::auto_ptr< awt::Size > pRefSize )
+ : MultipleItemConverter( rItemPool )
+{
+ for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ )
+ {
+ uno::Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) );
+ if(!xTitle.is())
+ continue;
+ uno::Reference< beans::XPropertySet > xObjectProperties( xTitle, uno::UNO_QUERY);
+ ::std::auto_ptr< awt::Size > pSingleRefSize(0);
+ if( pRefSize.get())
+ pSingleRefSize = ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize ));
+ m_aConverters.push_back( new ::chart::wrapper::TitleItemConverter(
+ xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, pSingleRefSize ));
+ }
+}
+
+AllTitleItemConverter::~AllTitleItemConverter()
+{
+}
+
+const sal_uInt16 * AllTitleItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nTitleWhichPairs;
+}
+
+//-----------------------------------------------------------------------------
+
+AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
+ const uno::Reference< frame::XModel > & xChartModel,
+ SfxItemPool& rItemPool )
+ : MultipleItemConverter( rItemPool )
+{
+ ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
+ ::chart::ChartModelHelper::getDataSeries( xChartModel ));
+
+ ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt;
+ for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt )
+ {
+ uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
+ m_aConverters.push_back( new ::chart::wrapper::StatisticsItemConverter(
+ xChartModel, xObjectProperties, rItemPool ));
+ }
+}
+
+AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter()
+{}
+
+const sal_uInt16 * AllSeriesStatisticsConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nStatWhichPairs;
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/MultipleItemConverter.cxx b/chart2/source/controller/itemsetwrapper/MultipleItemConverter.cxx
new file mode 100644
index 000000000000..b696d05088f4
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/MultipleItemConverter.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+#include "MultipleItemConverter.hxx"
+#include "ItemPropertyMap.hxx"
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+namespace comphelper
+{
+
+MultipleItemConverter::MultipleItemConverter( SfxItemPool& rItemPool )
+ : ItemConverter( NULL, rItemPool )
+{
+}
+MultipleItemConverter::~MultipleItemConverter()
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ DeleteItemConverterPtr() );
+}
+
+void MultipleItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
+{
+ ::std::vector< ItemConverter* >::const_iterator aIter = m_aConverters.begin();
+ const ::std::vector< ItemConverter* >::const_iterator aEnd = m_aConverters.end();
+ if( aIter != aEnd )
+ {
+ (*aIter)->FillItemSet( rOutItemSet );
+ aIter++;
+ }
+ for( ; aIter != aEnd; aIter++ )
+ {
+ SfxItemSet aSet = this->CreateEmptyItemSet();
+ (*aIter)->FillItemSet( aSet );
+ InvalidateUnequalItems( rOutItemSet, aSet );
+ }
+ // no own items
+}
+
+bool MultipleItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
+{
+ bool bResult = false;
+
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ApplyItemSetFunc( rItemSet, bResult ));
+
+ // no own items
+ return bResult;
+}
+
+bool MultipleItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyNameWithMemberId & /*rOutProperty*/ ) const
+{
+ return false;
+}
+
+} // namespace comphelper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
new file mode 100644
index 000000000000..e517fdd82702
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -0,0 +1,279 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// 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"
+#include "ItemPropertyMap.hxx"
+#include "GraphicPropertyItemConverter.hxx"
+
+#include <com/sun/star/chart2/XRegressionCurve.hpp>
+
+// for SfxBoolItem
+#include <svl/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
+{
+
+RegressionCurveItemConverter::RegressionCurveItemConverter(
+ const uno::Reference< beans::XPropertySet > & rPropertySet,
+ const uno::Reference< chart2::XRegressionCurveContainer > & xRegCurveCnt,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) :
+ ItemConverter( rPropertySet, rItemPool ),
+ m_spGraphicConverter( new GraphicPropertyItemConverter(
+ rPropertySet, rItemPool, rDrawModel,
+ xNamedPropertyContainerFactory,
+ GraphicPropertyItemConverter::LINE_PROPERTIES )),
+ m_xCurveContainer( xRegCurveCnt )
+{}
+
+RegressionCurveItemConverter::~RegressionCurveItemConverter()
+{}
+
+void RegressionCurveItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
+{
+ m_spGraphicConverter->FillItemSet( rOutItemSet );
+
+ // own items
+ ItemConverter::FillItemSet( rOutItemSet );
+}
+
+bool RegressionCurveItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
+{
+ bool bResult = m_spGraphicConverter->ApplyItemSet( rItemSet );
+
+ // own items
+ return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
+}
+
+const sal_uInt16 * RegressionCurveItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nRegressionCurveWhichPairs;
+}
+
+bool RegressionCurveItemConverter::GetItemProperty(
+ tWhichIdType /* nWhichId */, tPropertyNameWithMemberId & /* rOutProperty */ ) const
+{
+ // No own (non-special) properties
+ return false;
+}
+
+
+bool RegressionCurveItemConverter::ApplySpecialItem(
+ sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
+ throw( uno::Exception )
+{
+ uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
+ bool bChanged = false;
+
+ switch( nWhichId )
+ {
+ case SCHATTR_REGRESSION_TYPE:
+ {
+ 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:
+ {
+ OSL_ASSERT( xCurve.is());
+ if( xCurve.is())
+ {
+ bool bNewShow = static_cast< sal_Bool >(
+ static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue());
+
+ uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
+ OSL_ASSERT( xEqProp.is());
+ bool bOldShow = false;
+ if( xEqProp.is() &&
+ (xEqProp->getPropertyValue( C2U( "ShowEquation" )) >>= bOldShow) &&
+ bOldShow != bNewShow )
+ {
+ xEqProp->setPropertyValue( C2U( "ShowEquation" ), uno::makeAny( bNewShow ));
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_REGRESSION_SHOW_COEFF:
+ {
+ OSL_ASSERT( xCurve.is());
+ if( xCurve.is())
+ {
+ bool bNewShow = static_cast< sal_Bool >(
+ static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue());
+
+ uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
+ OSL_ASSERT( xEqProp.is());
+ bool bOldShow = false;
+ if( xEqProp.is() &&
+ (xEqProp->getPropertyValue( C2U( "ShowCorrelationCoefficient" )) >>= bOldShow) &&
+ bOldShow != bNewShow )
+ {
+ xEqProp->setPropertyValue( C2U( "ShowCorrelationCoefficient" ), uno::makeAny( bNewShow ));
+ bChanged = true;
+ }
+ }
+ }
+ break;
+ }
+
+ return bChanged;
+}
+
+void RegressionCurveItemConverter::FillSpecialItem(
+ sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+ throw( uno::Exception )
+{
+ uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY );
+
+ switch( nWhichId )
+ {
+ case SCHATTR_REGRESSION_TYPE:
+ {
+ OSL_ASSERT( xCurve.is());
+ if( xCurve.is())
+ {
+ SvxChartRegress eRegress = static_cast< SvxChartRegress >(
+ static_cast< sal_Int32 >( RegressionCurveHelper::getRegressionType( xCurve )));
+ rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE ));
+ }
+ }
+ break;
+
+ case SCHATTR_REGRESSION_SHOW_EQUATION:
+ {
+ OSL_ASSERT( xCurve.is());
+ if( xCurve.is())
+ {
+ uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
+ OSL_ASSERT( xEqProp.is());
+ bool bShow = false;
+ if( xEqProp.is() &&
+ (xEqProp->getPropertyValue( C2U( "ShowEquation" )) >>= bShow))
+ {
+ rOutItemSet.Put( SfxBoolItem( nWhichId, bShow ));
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_REGRESSION_SHOW_COEFF:
+ {
+ OSL_ASSERT( xCurve.is());
+ if( xCurve.is())
+ {
+ uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties());
+ OSL_ASSERT( xEqProp.is());
+ bool bShow = false;
+ if( xEqProp.is() &&
+ (xEqProp->getPropertyValue( C2U( "ShowCorrelationCoefficient" )) >>= bShow))
+ {
+ rOutItemSet.Put( SfxBoolItem( nWhichId, bShow ));
+ }
+ }
+ }
+ break;
+ }
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx
new file mode 100644
index 000000000000..0244bc6cba92
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx
@@ -0,0 +1,172 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+
+#include "RegressionEquationItemConverter.hxx"
+#include "SchWhichPairs.hxx"
+#include "macros.hxx"
+#include "ItemPropertyMap.hxx"
+#include "GraphicPropertyItemConverter.hxx"
+#include "CharacterPropertyItemConverter.hxx"
+#include "MultipleItemConverter.hxx"
+
+#include <svl/intitem.hxx>
+#include <rtl/math.hxx>
+
+#include <functional>
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+::comphelper::ItemPropertyMapType & lcl_GetEquationPropertyMap()
+{
+ static ::comphelper::ItemPropertyMapType aEquationPropertyMap;
+
+ return aEquationPropertyMap;
+};
+} // anonymous namespace
+
+namespace chart
+{
+namespace wrapper
+{
+
+RegressionEquationItemConverter::RegressionEquationItemConverter(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
+ ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize ) :
+ ItemConverter( rPropertySet, rItemPool )
+{
+ m_aConverters.push_back( new GraphicPropertyItemConverter(
+ rPropertySet, rItemPool, rDrawModel,
+ xNamedPropertyContainerFactory,
+ GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ));
+
+ m_aConverters.push_back( new CharacterPropertyItemConverter(
+ rPropertySet, rItemPool, pRefSize, C2U("ReferencePageSize")));
+
+}
+
+RegressionEquationItemConverter::~RegressionEquationItemConverter()
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::DeleteItemConverterPtr() );
+}
+
+void RegressionEquationItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::FillItemSetFunc( rOutItemSet ));
+
+ // own items
+ ItemConverter::FillItemSet( rOutItemSet );
+}
+
+bool RegressionEquationItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
+{
+ bool bResult = false;
+
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::ApplyItemSetFunc( rItemSet, bResult ));
+
+ // own items
+ return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
+}
+
+const sal_uInt16 * RegressionEquationItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nRegEquationWhichPairs;
+}
+
+bool RegressionEquationItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
+{
+ ::comphelper::ItemPropertyMapType & rMap( lcl_GetEquationPropertyMap());
+ ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
+
+ if( aIt == rMap.end())
+ return false;
+
+ rOutProperty =(*aIt).second;
+ return true;
+}
+
+bool RegressionEquationItemConverter::ApplySpecialItem(
+ sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
+ throw( uno::Exception )
+{
+ bool bChanged = false;
+
+ switch( nWhichId )
+ {
+ case SID_ATTR_NUMBERFORMAT_VALUE:
+ {
+ uno::Any aValue( static_cast< sal_Int32 >(
+ static_cast< const SfxUInt32Item & >(
+ rItemSet.Get( nWhichId )).GetValue()));
+ if( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) != aValue )
+ {
+ GetPropertySet()->setPropertyValue( C2U( "NumberFormat" ), aValue );
+ bChanged = true;
+ }
+ }
+ break;
+ }
+
+ return bChanged;
+}
+
+void RegressionEquationItemConverter::FillSpecialItem(
+ sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+ throw( uno::Exception )
+{
+ switch( nWhichId )
+ {
+ case SID_ATTR_NUMBERFORMAT_VALUE:
+ {
+ sal_Int32 nFormatKey = 0;
+ if( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) >>= nFormatKey )
+ {
+ rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey ));
+ }
+ }
+ break;
+ }
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx
new file mode 100644
index 000000000000..7a842dfe2174
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx
@@ -0,0 +1,241 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CHART_SCHWHICHPAIRS_HXX
+#define CHART_SCHWHICHPAIRS_HXX
+
+#include <svx/svxids.hrc>
+#include <svx/xdef.hxx>
+#include <svx/svddef.hxx>
+#include <editeng/eeitem.hxx>
+
+#include "chartview/ChartSfxItemIds.hxx"
+
+namespace
+{
+
+#define CHARACTER_WHICHPAIRS \
+ EE_ITEMS_START, EE_ITEMS_END, \
+ SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING
+
+const sal_uInt16 nTitleWhichPairs[] =
+{
+ SCHATTR_TEXT_START, SCHATTR_TEXT_END,
+ XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx
+ XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx
+ SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx
+ CHARACTER_WHICHPAIRS,
+ 0
+};
+
+const sal_uInt16 nAxisWhichPairs[] =
+{
+ XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx
+ CHARACTER_WHICHPAIRS,
+ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE, // 10585 - 10585 svx/svxids.hrc
+ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, // 11432 svx/svxids.hrc
+ SCHATTR_AXIS_START, SCHATTR_AXIS_END,
+ SCHATTR_TEXT_START, SCHATTR_TEXT_END,
+ 0
+};
+
+const sal_uInt16 nAllAxisWhichPairs[] =
+{
+ XATTR_LINE_FIRST, XATTR_LINE_LAST,
+ CHARACTER_WHICHPAIRS,
+ SCHATTR_AXIS_LABEL_START, SCHATTR_AXIS_LABEL_END,
+ SCHATTR_TEXT_START, SCHATTR_TEXT_END,
+ 0
+};
+
+const sal_uInt16 nGridWhichPairs[] =
+{
+ XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx
+ 0
+};
+
+const sal_uInt16 nLegendWhichPairs[] =
+{
+ XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx
+ XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx
+ SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx
+ CHARACTER_WHICHPAIRS,
+ SCHATTR_LEGEND_START, SCHATTR_LEGEND_END, // 3 - 3 sch/schattr.hxx
+ 0
+};
+
+const sal_uInt16 nDataLabelWhichPairs[] =
+{
+ SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END,
+ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ \
+ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ \
+ SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES,
+ EE_PARA_WRITINGDIR,EE_PARA_WRITINGDIR,
+ 0
+};
+
+#define CHART_POINT_WHICHPAIRS \
+ XATTR_LINE_FIRST, XATTR_LINE_LAST, /* 1000 - 1016 svx/xdef.hxx */ \
+ XATTR_FILL_FIRST, XATTR_FILL_LAST, /* 1018 - 1046 svx/xdef.hxx */ \
+ EE_ITEMS_START, EE_ITEMS_END, /* 3994 - 4037 editeng/eeitem.hxx */ \
+ SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING, \
+ SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, /* 1 - 2 sch/schattr.hxx*/ \
+ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ \
+ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ \
+ SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, \
+ SCHATTR_STYLE_START,SCHATTR_STYLE_END, /* 59 - 68 sch/schattr.hxx*/ \
+ SCHATTR_SYMBOL_BRUSH,SCHATTR_SYMBOL_BRUSH, /* 94 sch/schattr.hxx*/ \
+ SCHATTR_SYMBOL_SIZE,SCHATTR_SYMBOL_SIZE, /* 97 sch/schattr.hxx*/ \
+ SDRATTR_3D_FIRST, SDRATTR_3D_LAST /* 1244 - 1334 svx/svddef.hxx */
+
+const sal_uInt16 nDataPointWhichPairs[] =
+{
+ CHART_POINT_WHICHPAIRS,
+ 0
+};
+
+#define CHART_SERIES_OPTIONS_WHICHPAIRS \
+ SCHATTR_AXIS,SCHATTR_AXIS, /* 69 sch/schattr.hxx*/ \
+ SCHATTR_BAR_OVERLAP,SCHATTR_BAR_CONNECT, /* 98 - 100 (incl. SCHATTR_GAPWIDTH) */ \
+ SCHATTR_GROUP_BARS_PER_AXIS,SCHATTR_AXIS_FOR_ALL_SERIES, \
+ SCHATTR_STARTING_ANGLE,SCHATTR_STARTING_ANGLE, \
+ SCHATTR_CLOCKWISE,SCHATTR_CLOCKWISE, \
+ SCHATTR_MISSING_VALUE_TREATMENT,SCHATTR_MISSING_VALUE_TREATMENT, \
+ SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS,SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, \
+ SCHATTR_INCLUDE_HIDDEN_CELLS,SCHATTR_INCLUDE_HIDDEN_CELLS
+
+const sal_uInt16 nSeriesOptionsWhichPairs[] =
+{
+ CHART_SERIES_OPTIONS_WHICHPAIRS,
+ 0
+};
+
+const sal_uInt16 nRowWhichPairs[] =
+{
+ CHART_POINT_WHICHPAIRS,
+ CHART_SERIES_OPTIONS_WHICHPAIRS,
+ 0
+};
+
+const sal_uInt16 nAreaWhichPairs[] =
+{
+ XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx
+ XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1000 - 1016 svx/xdef.hxx
+ SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx
+ 0
+};
+
+const sal_uInt16 nTextWhichPairs[] =
+{
+ CHARACTER_WHICHPAIRS,
+ SCHATTR_TEXT_START, SCHATTR_TEXT_END,
+ 0
+};
+
+const sal_uInt16 nTextOrientWhichPairs[] =
+{
+ CHARACTER_WHICHPAIRS,
+ SCHATTR_TEXT_START, SCHATTR_TEXT_END,
+ 0
+};
+
+const sal_uInt16 nStatWhichPairs[]=
+{
+ SCHATTR_STAT_START, SCHATTR_STAT_END, // 45 - 52 sch/schattr.hxx
+ SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END, // 108 - 109
+ 0
+};
+
+const sal_uInt16 nErrorBarWhichPairs[]=
+{
+ SCHATTR_STAT_START, SCHATTR_STAT_END, // 45 - 52 sch/schattr.hxx
+ XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx
+ 0
+};
+
+// for CharacterProperties
+
+const sal_uInt16 nCharacterPropertyWhichPairs[] =
+{
+ CHARACTER_WHICHPAIRS,
+ 0
+};
+
+const sal_uInt16 nLinePropertyWhichPairs[] =
+{
+ XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx
+ 0
+};
+
+const sal_uInt16 nFillPropertyWhichPairs[] =
+{
+ XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1000 - 1016 svx/xdef.hxx
+ SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx
+ 0
+};
+
+const sal_uInt16 nLineAndFillPropertyWhichPairs[] =
+{
+ XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx
+ XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1000 - 1016 svx/xdef.hxx
+ SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx
+ 0
+};
+
+const sal_uInt16 nChartStyleWhichPairs[] =
+{
+ SCHATTR_DIAGRAM_STYLE, SCHATTR_DIAGRAM_STYLE,
+ SCHATTR_STYLE_SHAPE, SCHATTR_STYLE_SHAPE,
+ SCHATTR_NUM_OF_LINES_FOR_BAR, SCHATTR_NUM_OF_LINES_FOR_BAR,
+ SCHATTR_SPLINE_ORDER, SCHATTR_SPLINE_ORDER,
+ SCHATTR_SPLINE_RESOLUTION, SCHATTR_SPLINE_RESOLUTION,
+ 0
+};
+
+const sal_uInt16 nRegressionCurveWhichPairs[] =
+{
+ SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END, // 108 - 109
+ XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx
+ 0
+};
+
+const sal_uInt16 nRegEquationWhichPairs[] =
+{
+ XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx
+ XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx
+ SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx
+ CHARACTER_WHICHPAIRS,
+ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE, // 10585 - 10585 svx/svxids.hrc
+ 0
+};
+
+} // anonymous namespace
+
+// CHART_SCHWHICHPAIRS_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
new file mode 100644
index 000000000000..1782d9513caa
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
@@ -0,0 +1,456 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+
+#include "SeriesOptionsItemConverter.hxx"
+#include "SchWhichPairs.hxx"
+
+#include "macros.hxx"
+#include "ItemPropertyMap.hxx"
+#include "GraphicPropertyItemConverter.hxx"
+#include "MultipleItemConverter.hxx"
+#include "ChartModelHelper.hxx"
+#include "AxisHelper.hxx"
+#include "DiagramHelper.hxx"
+#include "ChartTypeHelper.hxx"
+#include "DataSeriesHelper.hxx"
+
+#include <com/sun/star/chart/MissingValueTreatment.hpp>
+#include <com/sun/star/chart2/XDataSeries.hpp>
+
+// for SfxBoolItem
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+
+//SfxIntegerListItem
+#include <svl/ilstitem.hxx>
+#define _SVSTDARR_ULONGS
+#include <svl/svstdarr.hxx>
+
+#include <rtl/math.hxx>
+#include <functional>
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+
+namespace chart
+{
+namespace wrapper
+{
+
+// ========================================
+
+SeriesOptionsItemConverter::SeriesOptionsItemConverter(
+ const uno::Reference< frame::XModel >& xChartModel
+ , const uno::Reference< uno::XComponentContext > & xContext
+ , const uno::Reference< beans::XPropertySet >& xPropertySet
+ , SfxItemPool& rItemPool )
+ : ItemConverter( xPropertySet, rItemPool )
+ , m_xChartModel(xChartModel)
+ , m_xCC(xContext)
+ , m_bAttachToMainAxis(true)
+ , m_bSupportingOverlapAndGapWidthProperties(false)
+ , m_bSupportingBarConnectors(false)
+ , m_nBarOverlap(0)
+ , m_nGapWidth(100)
+ , m_bConnectBars(false)
+ , m_bSupportingAxisSideBySide(false)
+ , m_bGroupBarsPerAxis(true)
+ , m_bAllSeriesAttachedToSameAxis(true)
+ , m_nAllSeriesAxisIndex(-1)
+ , m_bSupportingStartingAngle(false)
+ , m_nStartingAngle(90)
+ , m_bClockwise(false)
+ , m_aSupportedMissingValueTreatments()
+ , m_nMissingValueTreatment(0)
+ , m_bSupportingPlottingOfHiddenCells(false)
+ , m_bIncludeHiddenCells(true)
+{
+ try
+ {
+ uno::Reference< XDataSeries > xDataSeries( xPropertySet, uno::UNO_QUERY );
+
+ m_bAttachToMainAxis = DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries );
+
+ uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) );
+ uno::Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY );
+ uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ) );
+
+ m_xCooSys = DataSeriesHelper::getCoordinateSystemOfSeries( xDataSeries, xDiagram );
+ if( m_xCooSys.is() )
+ {
+ uno::Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1, 0, m_xCooSys ) );
+ chart2::ScaleData aScale( xAxis->getScaleData() );
+ m_bClockwise = (aScale.Orientation == chart2::AxisOrientation_REVERSE);
+ }
+
+ sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+ m_bSupportingOverlapAndGapWidthProperties = ChartTypeHelper::isSupportingOverlapAndGapWidthProperties( xChartType, nDimensionCount );
+
+ if( m_bSupportingOverlapAndGapWidthProperties )
+ {
+
+ sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries);
+
+ uno::Sequence< sal_Int32 > m_aBarPositionSequence;
+ uno::Reference< beans::XPropertySet > xChartTypeProps( xChartType, uno::UNO_QUERY );
+ if( xChartTypeProps.is() )
+ {
+ if( xChartTypeProps->getPropertyValue( C2U( "OverlapSequence" ) ) >>= m_aBarPositionSequence )
+ {
+ if( nAxisIndex >= 0 && nAxisIndex < m_aBarPositionSequence.getLength() )
+ m_nBarOverlap = m_aBarPositionSequence[nAxisIndex];
+ }
+ if( xChartTypeProps->getPropertyValue( C2U( "GapwidthSequence" ) ) >>= m_aBarPositionSequence )
+ {
+ if( nAxisIndex >= 0 && nAxisIndex < m_aBarPositionSequence.getLength() )
+ m_nGapWidth = m_aBarPositionSequence[nAxisIndex];
+ }
+ }
+ }
+
+ m_bSupportingBarConnectors = ChartTypeHelper::isSupportingBarConnectors( xChartType, nDimensionCount );
+ if( m_bSupportingBarConnectors && xDiagramProperties.is() )
+ {
+ xDiagramProperties->getPropertyValue( C2U("ConnectBars")) >>= m_bConnectBars;
+ }
+
+ m_bSupportingAxisSideBySide = ChartTypeHelper::isSupportingAxisSideBySide( xChartType, nDimensionCount );
+ if( m_bSupportingAxisSideBySide && xDiagramProperties.is() )
+ {
+ xDiagramProperties->getPropertyValue( C2U("GroupBarsPerAxis")) >>= m_bGroupBarsPerAxis;
+ m_bAllSeriesAttachedToSameAxis = DataSeriesHelper::areAllSeriesAttachedToSameAxis( xChartType, m_nAllSeriesAxisIndex );
+ }
+
+ m_bSupportingStartingAngle = ChartTypeHelper::isSupportingStartingAngle( xChartType );
+ if( m_bSupportingStartingAngle )
+ {
+ xDiagramProperties->getPropertyValue( C2U( "StartingAngle" ) ) >>= m_nStartingAngle;
+ }
+
+ m_aSupportedMissingValueTreatments = ChartTypeHelper::getSupportedMissingValueTreatments( xChartType );
+ m_nMissingValueTreatment = DiagramHelper::getCorrectedMissingValueTreatment(
+ ChartModelHelper::findDiagram(m_xChartModel), xChartType );
+
+ uno::Reference< XChartDocument > xChartDoc( m_xChartModel, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProp( xChartDoc->getDataProvider(), uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ try
+ {
+ //test whether the data provider offers this property
+ xProp->getPropertyValue(C2U("IncludeHiddenCells"));
+ //if not exception is thrown the property is offered
+ m_bSupportingPlottingOfHiddenCells = true;
+ xDiagramProperties->getPropertyValue( C2U("IncludeHiddenCells") ) >>= m_bIncludeHiddenCells;
+ }
+ catch( const beans::UnknownPropertyException& )
+ {
+ }
+ }
+ }
+ catch( uno::Exception &ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+}
+
+SeriesOptionsItemConverter::~SeriesOptionsItemConverter()
+{
+}
+
+const sal_uInt16 * SeriesOptionsItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nSeriesOptionsWhichPairs;
+}
+
+bool SeriesOptionsItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyNameWithMemberId & /*rOutProperty*/ ) const
+{
+ return false;
+}
+
+bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
+ throw( uno::Exception )
+{
+ bool bChanged = false;
+ switch( nWhichId )
+ {
+ case SCHATTR_AXIS:
+ {
+ sal_Int32 nItemValue = static_cast< const SfxInt32Item & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ bool bAttachToMainAxis = nItemValue == CHART_AXIS_PRIMARY_Y;
+ if( bAttachToMainAxis != m_bAttachToMainAxis )
+ {
+ //change model:
+ bChanged = DiagramHelper::attachSeriesToAxis( bAttachToMainAxis, uno::Reference< XDataSeries >::query( GetPropertySet() )
+ , ChartModelHelper::findDiagram(m_xChartModel), m_xCC );
+
+ if( bChanged )
+ m_bAttachToMainAxis = bAttachToMainAxis;
+ }
+ }
+ break;
+
+ case SCHATTR_BAR_OVERLAP:
+ case SCHATTR_BAR_GAPWIDTH:
+ {
+ if( m_bSupportingOverlapAndGapWidthProperties )
+ {
+ sal_Int32& rBarPosition = ( SCHATTR_BAR_OVERLAP == nWhichId ) ? m_nBarOverlap : m_nGapWidth;
+ rBarPosition = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
+
+ rtl::OUString aPropName( C2U( "GapwidthSequence" ) );
+ if( SCHATTR_BAR_OVERLAP == nWhichId )
+ aPropName = C2U( "OverlapSequence" );
+
+ uno::Reference< XDataSeries > xDataSeries( GetPropertySet(), uno::UNO_QUERY );
+ uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(m_xChartModel) );
+ uno::Reference< beans::XPropertySet > xChartTypeProps( DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ), uno::UNO_QUERY );
+ if( xChartTypeProps.is() )
+ {
+ sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries);
+ uno::Sequence< sal_Int32 > m_aBarPositionSequence;
+ if( xChartTypeProps.is() )
+ {
+ if( xChartTypeProps->getPropertyValue( aPropName ) >>= m_aBarPositionSequence )
+ {
+ bool bGroupBarsPerAxis = static_cast< const SfxBoolItem & >(rItemSet.Get( SCHATTR_GROUP_BARS_PER_AXIS )).GetValue();
+ if(!bGroupBarsPerAxis)
+ {
+ //set the same value for all axes
+ for( sal_Int32 nN = 0; nN < m_aBarPositionSequence.getLength(); nN++ )
+ m_aBarPositionSequence[nN] = rBarPosition;
+ }
+ else if( nAxisIndex >= 0 && nAxisIndex < m_aBarPositionSequence.getLength() )
+ m_aBarPositionSequence[nAxisIndex] = rBarPosition;
+
+ xChartTypeProps->setPropertyValue( aPropName, uno::makeAny(m_aBarPositionSequence) );
+ bChanged = true;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_BAR_CONNECT:
+ {
+ sal_Bool bOldConnectBars = sal_False;
+ m_bConnectBars = static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ if( m_bSupportingBarConnectors )
+ {
+ uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY );
+ if( xDiagramProperties.is() &&
+ (xDiagramProperties->getPropertyValue( C2U("ConnectBars")) >>= bOldConnectBars) &&
+ bOldConnectBars != m_bConnectBars )
+ {
+ xDiagramProperties->setPropertyValue( C2U("ConnectBars"), uno::makeAny(m_bConnectBars) );
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_GROUP_BARS_PER_AXIS:
+ {
+ bool bOldGroupBarsPerAxis = true;
+ m_bGroupBarsPerAxis = static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ if( m_bSupportingAxisSideBySide )
+ {
+ uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY );
+ if( xDiagramProperties.is() &&
+ (xDiagramProperties->getPropertyValue( C2U("GroupBarsPerAxis")) >>= bOldGroupBarsPerAxis) &&
+ bOldGroupBarsPerAxis != m_bGroupBarsPerAxis )
+ {
+ xDiagramProperties->setPropertyValue( C2U("GroupBarsPerAxis"), uno::makeAny(m_bGroupBarsPerAxis) );
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_STARTING_ANGLE:
+ {
+ if( m_bSupportingStartingAngle )
+ {
+ m_nStartingAngle = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
+ uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY );
+ if( xDiagramProperties.is() )
+ {
+ xDiagramProperties->setPropertyValue( C2U("StartingAngle"), uno::makeAny(m_nStartingAngle) );
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_CLOCKWISE:
+ {
+ bool bClockwise = (static_cast< const SfxBoolItem & >(
+ rItemSet.Get( nWhichId )).GetValue() );
+ if( m_xCooSys.is() )
+ {
+ uno::Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1, 0, m_xCooSys ) );
+ if( xAxis.is() )
+ {
+ chart2::ScaleData aScaleData( xAxis->getScaleData() );
+ aScaleData.Orientation = bClockwise ? chart2::AxisOrientation_REVERSE : chart2::AxisOrientation_MATHEMATICAL;
+ xAxis->setScaleData( aScaleData );
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_MISSING_VALUE_TREATMENT:
+ {
+ if( m_aSupportedMissingValueTreatments.getLength() )
+ {
+ sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
+ if( m_nMissingValueTreatment != nNew )
+ {
+ try
+ {
+ uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY );
+ if( xDiagramProperties.is() )
+ {
+ xDiagramProperties->setPropertyValue( C2U( "MissingValueTreatment" ), uno::makeAny( nNew ));
+ bChanged = true;
+ }
+ }
+ catch( uno::Exception& e )
+ {
+ ASSERT_EXCEPTION( e );
+ }
+ }
+ }
+ }
+ break;
+ case SCHATTR_INCLUDE_HIDDEN_CELLS:
+ {
+ if( m_bSupportingPlottingOfHiddenCells )
+ {
+ bool bIncludeHiddenCells = static_cast<const SfxBoolItem &>(rItemSet.Get(nWhichId)).GetValue();
+ if (bIncludeHiddenCells != m_bIncludeHiddenCells)
+ bChanged = ChartModelHelper::setIncludeHiddenCells( bIncludeHiddenCells, m_xChartModel );
+ }
+ }
+ break;
+ }
+ return bChanged;
+}
+
+void SeriesOptionsItemConverter::FillSpecialItem(
+ sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+ throw( uno::Exception )
+{
+ switch( nWhichId )
+ {
+ case SCHATTR_AXIS:
+ {
+ sal_Int32 nItemValue = m_bAttachToMainAxis ? CHART_AXIS_PRIMARY_Y : CHART_AXIS_SECONDARY_Y;
+ rOutItemSet.Put( SfxInt32Item(nWhichId,nItemValue ) );
+ break;
+ }
+ case SCHATTR_BAR_OVERLAP:
+ {
+ if( m_bSupportingOverlapAndGapWidthProperties )
+ rOutItemSet.Put( SfxInt32Item(nWhichId,m_nBarOverlap) );
+ break;
+ }
+ case SCHATTR_BAR_GAPWIDTH:
+ {
+ if( m_bSupportingOverlapAndGapWidthProperties )
+ rOutItemSet.Put( SfxInt32Item(nWhichId,m_nGapWidth) );
+ break;
+ }
+ case SCHATTR_BAR_CONNECT:
+ {
+ if( m_bSupportingBarConnectors )
+ rOutItemSet.Put( SfxBoolItem(nWhichId,m_bConnectBars));
+ break;
+ }
+ case SCHATTR_GROUP_BARS_PER_AXIS:
+ {
+ if( m_bSupportingAxisSideBySide )
+ rOutItemSet.Put( SfxBoolItem(nWhichId,m_bGroupBarsPerAxis) );
+ break;
+ }
+ case SCHATTR_AXIS_FOR_ALL_SERIES:
+ {
+ if( m_nAllSeriesAxisIndex != - 1)
+ rOutItemSet.Put( SfxInt32Item(nWhichId, m_nAllSeriesAxisIndex));
+ break;
+ }
+ case SCHATTR_STARTING_ANGLE:
+ {
+ if( m_bSupportingStartingAngle )
+ rOutItemSet.Put( SfxInt32Item(nWhichId,m_nStartingAngle));
+ break;
+ }
+ case SCHATTR_CLOCKWISE:
+ {
+ rOutItemSet.Put( SfxBoolItem(nWhichId,m_bClockwise) );
+ break;
+ }
+ case SCHATTR_MISSING_VALUE_TREATMENT:
+ {
+ if( m_aSupportedMissingValueTreatments.getLength() )
+ rOutItemSet.Put( SfxInt32Item( nWhichId, m_nMissingValueTreatment ));
+ break;
+ }
+ case SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS:
+ {
+ SvULongs aList;
+ for ( sal_Int32 nN=0; nN<m_aSupportedMissingValueTreatments.getLength(); nN++ )
+ aList.Insert( m_aSupportedMissingValueTreatments[nN], sal::static_int_cast< sal_uInt16 >(nN) );
+ rOutItemSet.Put( SfxIntegerListItem( nWhichId, aList ) );
+ break;
+ }
+ case SCHATTR_INCLUDE_HIDDEN_CELLS:
+ {
+ if( m_bSupportingPlottingOfHiddenCells )
+ rOutItemSet.Put( SfxBoolItem(nWhichId, m_bIncludeHiddenCells) );
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
new file mode 100644
index 000000000000..60b5141c3a9c
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -0,0 +1,700 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+#include "StatisticsItemConverter.hxx"
+#include "SchWhichPairs.hxx"
+#include "macros.hxx"
+#include "RegressionCurveHelper.hxx"
+#include "ItemPropertyMap.hxx"
+#include "ErrorBar.hxx"
+#include "PropertyHelper.hxx"
+#include "ChartModelHelper.hxx"
+#include "ChartTypeHelper.hxx"
+#include "StatisticsHelper.hxx"
+
+#include "GraphicPropertyItemConverter.hxx"
+
+#include <svl/stritem.hxx>
+#include <svx/chrtitem.hxx>
+#include <svl/intitem.hxx>
+#include <rtl/math.hxx>
+
+#include <com/sun/star/chart2/DataPointLabel.hpp>
+#include <com/sun/star/chart2/XInternalDataProvider.hpp>
+#include <com/sun/star/chart/ErrorBarStyle.hpp>
+#include <com/sun/star/lang/XServiceName.hpp>
+
+#include <functional>
+#include <algorithm>
+#include <vector>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+
+uno::Reference< beans::XPropertySet > lcl_GetYErrorBar(
+ const uno::Reference< beans::XPropertySet > & xProp )
+{
+ uno::Reference< beans::XPropertySet > xResult;
+
+ if( xProp.is())
+ try
+ {
+ ( xProp->getPropertyValue( C2U( "ErrorBarY" )) >>= xResult );
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+
+ return xResult;
+}
+
+::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;
+}
+
+
+uno::Reference< beans::XPropertySet > lcl_GetDefaultErrorBar()
+{
+ // todo: use a valid context
+ return uno::Reference< beans::XPropertySet >(
+ ::chart::createErrorBar( uno::Reference< uno::XComponentContext >()));
+}
+
+void lcl_getErrorValues( const uno::Reference< beans::XPropertySet > & xErrorBarProp,
+ double & rOutPosError, double & rOutNegError )
+{
+ if( ! xErrorBarProp.is())
+ return;
+
+ try
+ {
+ xErrorBarProp->getPropertyValue( C2U( "PositiveError" )) >>= rOutPosError;
+ xErrorBarProp->getPropertyValue( C2U( "NegativeError" )) >>= rOutNegError;
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+}
+
+void lcl_getErrorIndicatorValues(
+ const uno::Reference< beans::XPropertySet > & xErrorBarProp,
+ bool & rOutShowPosError, bool & rOutShowNegError )
+{
+ if( ! xErrorBarProp.is())
+ return;
+
+ try
+ {
+ xErrorBarProp->getPropertyValue( C2U( "ShowPositiveError" )) >>= rOutShowPosError;
+ xErrorBarProp->getPropertyValue( C2U( "ShowNegativeError" )) >>= rOutShowNegError;
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+}
+
+uno::Reference< beans::XPropertySet > lcl_getEquationProperties(
+ const uno::Reference< beans::XPropertySet > & xSeriesPropSet, const SfxItemSet * pItemSet )
+{
+ bool bEquationExists = true;
+
+ // ensure that a trendline is on
+ if( pItemSet )
+ {
+ SvxChartRegress eRegress = CHREGRESS_NONE;
+ const SfxPoolItem *pPoolItem = NULL;
+ if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, sal_True, &pPoolItem ) == SFX_ITEM_SET )
+ {
+ eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue();
+ bEquationExists = ( eRegress != CHREGRESS_NONE );
+ }
+ }
+
+ if( bEquationExists )
+ {
+ uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropSet, uno::UNO_QUERY );
+ uno::Reference< chart2::XRegressionCurve > xCurve(
+ ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt ));
+ if( xCurve.is())
+ {
+ return xCurve->getEquationProperties();
+ }
+ }
+
+ return uno::Reference< beans::XPropertySet >();
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+namespace wrapper
+{
+
+StatisticsItemConverter::StatisticsItemConverter(
+ const uno::Reference< frame::XModel > & xModel,
+ const uno::Reference< beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool ) :
+ ItemConverter( rPropertySet, rItemPool ),
+ m_xModel( xModel )
+{
+ OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_NONE ) ==
+ static_cast< int >( CHREGRESS_NONE ));
+ OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_LINEAR ) ==
+ static_cast< int >( CHREGRESS_LINEAR ));
+ OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_LOG ) ==
+ static_cast< int >( CHREGRESS_LOG ));
+ OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_EXP ) ==
+ static_cast< int >( CHREGRESS_EXP ));
+ OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_POWER ) ==
+ static_cast< int >( CHREGRESS_POWER ));
+}
+
+StatisticsItemConverter::~StatisticsItemConverter()
+{}
+
+const sal_uInt16 * StatisticsItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nStatWhichPairs;
+}
+
+bool StatisticsItemConverter::GetItemProperty(
+ tWhichIdType /* nWhichId */,
+ tPropertyNameWithMemberId & /* rOutProperty */ ) const
+{
+ return false;
+}
+
+bool StatisticsItemConverter::ApplySpecialItem(
+ sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
+ throw( uno::Exception )
+{
+ bool bChanged = false;
+ uno::Any aValue;
+
+ switch( nWhichId )
+ {
+ case SCHATTR_STAT_AVERAGE:
+ {
+ uno::Reference< chart2::XRegressionCurveContainer > xRegCnt(
+ GetPropertySet(), uno::UNO_QUERY );
+ bool bOldHasMeanValueLine = RegressionCurveHelper::hasMeanValueLine( xRegCnt );
+
+ bool bNewHasMeanValueLine =
+ static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
+
+ if( bOldHasMeanValueLine != bNewHasMeanValueLine )
+ {
+ if( ! bNewHasMeanValueLine )
+ RegressionCurveHelper::removeMeanValueLine( xRegCnt );
+ else
+ RegressionCurveHelper::addMeanValueLine(
+ xRegCnt, uno::Reference< uno::XComponentContext >(), GetPropertySet() );
+ bChanged = true;
+ }
+ }
+ break;
+
+ // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT,
+ // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS,
+ // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE
+ case SCHATTR_STAT_KIND_ERROR:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp(
+ lcl_GetYErrorBar( GetPropertySet() ));
+
+ SvxChartKindError eErrorKind =
+ static_cast< const SvxChartKindErrorItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+
+ if( !xErrorBarProp.is() && eErrorKind == CHERROR_NONE)
+ {
+ //nothing to do
+ }
+ else
+ {
+ sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
+
+ switch( eErrorKind )
+ {
+ case CHERROR_NONE:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; break;
+ case CHERROR_VARIANT:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::VARIANCE; break;
+ case CHERROR_SIGMA:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION; break;
+ case CHERROR_PERCENT:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE; break;
+ case CHERROR_BIGERROR:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN; break;
+ case CHERROR_CONST:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE; break;
+ case CHERROR_STDERROR:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR; break;
+ case CHERROR_RANGE:
+ nStyle = ::com::sun::star::chart::ErrorBarStyle::FROM_DATA; break;
+ }
+
+ if( !xErrorBarProp.is() )
+ {
+ xErrorBarProp = lcl_GetDefaultErrorBar();
+ GetPropertySet()->setPropertyValue(
+ C2U( "ErrorBarY" ), uno::makeAny( xErrorBarProp ));
+ }
+
+ xErrorBarProp->setPropertyValue( C2U( "ErrorBarStyle" ),
+ uno::makeAny( nStyle ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_PERCENT:
+ case SCHATTR_STAT_BIGERROR:
+ {
+ OSL_FAIL( "Deprectaed item" );
+ uno::Reference< beans::XPropertySet > xErrorBarProp(
+ lcl_GetYErrorBar( GetPropertySet()));
+ bool bOldHasErrorBar = xErrorBarProp.is();
+
+ double fValue =
+ static_cast< const SvxDoubleItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ double fPos, fNeg;
+ lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
+
+ if( bOldHasErrorBar &&
+ ! ( ::rtl::math::approxEqual( fPos, fValue ) &&
+ ::rtl::math::approxEqual( fNeg, fValue )))
+ {
+ xErrorBarProp->setPropertyValue( C2U( "PositiveError" ),
+ uno::makeAny( fValue ));
+ xErrorBarProp->setPropertyValue( C2U( "NegativeError" ),
+ uno::makeAny( fValue ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_CONSTPLUS:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp(
+ lcl_GetYErrorBar( GetPropertySet()));
+ bool bOldHasErrorBar = xErrorBarProp.is();
+
+ double fValue =
+ static_cast< const SvxDoubleItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ double fPos, fNeg;
+ lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
+
+ if( bOldHasErrorBar &&
+ ! ::rtl::math::approxEqual( fPos, fValue ))
+ {
+ xErrorBarProp->setPropertyValue( C2U( "PositiveError" ), uno::makeAny( fValue ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_CONSTMINUS:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp(
+ lcl_GetYErrorBar( GetPropertySet()));
+ bool bOldHasErrorBar = xErrorBarProp.is();
+
+ double fValue =
+ static_cast< const SvxDoubleItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+ double fPos, fNeg;
+ lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
+
+ if( bOldHasErrorBar &&
+ ! ::rtl::math::approxEqual( fNeg, fValue ))
+ {
+ xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), uno::makeAny( fValue ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_REGRESSION_TYPE:
+ {
+ SvxChartRegress eRegress =
+ static_cast< const SvxChartRegressItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+
+ uno::Reference< chart2::XRegressionCurveContainer > xRegCnt(
+ GetPropertySet(), uno::UNO_QUERY );
+
+ if( eRegress == CHREGRESS_NONE )
+ {
+ bChanged = RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCnt );
+ }
+ else
+ {
+ SvxChartRegress eOldRegress(
+ static_cast< SvxChartRegress >(
+ static_cast< sal_Int32 >(
+ RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( xRegCnt ))));
+ if( eOldRegress != eRegress )
+ {
+ RegressionCurveHelper::replaceOrAddCurveAndReduceToOne(
+ lcl_convertRegressionType( eRegress ), xRegCnt,
+ uno::Reference< uno::XComponentContext >());
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_REGRESSION_SHOW_EQUATION:
+ {
+ uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
+ if( xEqProp.is())
+ {
+ bool bShowEq = false;
+ xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq;
+ bool bNewShowEq =
+ static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
+ if( bShowEq != bNewShowEq )
+ {
+ xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( bNewShowEq ));
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_REGRESSION_SHOW_COEFF:
+ {
+ uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
+ if( xEqProp.is())
+ {
+ bool bShowCoeff = false;
+ xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoeff;
+ bool bNewShowCoeff =
+ static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
+ if( bShowCoeff != bNewShowCoeff )
+ {
+ xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bNewShowCoeff ));
+ bChanged = true;
+ }
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_INDICATE:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp(
+ lcl_GetYErrorBar( GetPropertySet()));
+ bool bOldHasErrorBar = xErrorBarProp.is();
+
+ SvxChartIndicate eIndicate =
+ static_cast< const SvxChartIndicateItem & >(
+ rItemSet.Get( nWhichId )).GetValue();
+
+ bool bNewIndPos = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_UP );
+ bool bNewIndNeg = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_DOWN );
+
+ bool bShowPos, bShowNeg;
+ lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg );
+
+ if( bOldHasErrorBar &&
+ ( bShowPos != bNewIndPos ||
+ bShowNeg != bNewIndNeg ))
+ {
+ xErrorBarProp->setPropertyValue( C2U( "ShowPositiveError" ), uno::makeAny( bNewIndPos ));
+ xErrorBarProp->setPropertyValue( C2U( "ShowNegativeError" ), uno::makeAny( bNewIndNeg ));
+ bChanged = true;
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_RANGE_POS:
+ case SCHATTR_STAT_RANGE_NEG:
+ {
+ // @todo: also be able to deal with x-error bars
+ const bool bYError = true;
+ uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), uno::UNO_QUERY );
+ uno::Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY );
+ uno::Reference< chart2::data::XDataProvider > xDataProvider;
+
+ if( xChartDoc.is())
+ xDataProvider.set( xChartDoc->getDataProvider());
+ if( xErrorBarSource.is() && xDataProvider.is())
+ {
+ ::rtl::OUString aNewRange( static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue());
+ bool bApplyNewRange = false;
+
+ bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS );
+ if( xChartDoc->hasInternalDataProvider())
+ {
+ if( aNewRange.getLength())
+ {
+ uno::Reference< chart2::data::XDataSequence > xSeq(
+ StatisticsHelper::getErrorDataSequenceFromDataSource(
+ xErrorBarSource, bIsPositiveValue, bYError ));
+ if( ! xSeq.is())
+ {
+ // no data range for error bars yet => create
+ uno::Reference< chart2::XInternalDataProvider > xIntDataProvider( xDataProvider, uno::UNO_QUERY );
+ OSL_ASSERT( xIntDataProvider.is());
+ if( xIntDataProvider.is())
+ {
+ xIntDataProvider->appendSequence();
+ aNewRange = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("last"));
+ bApplyNewRange = true;
+ }
+ }
+ }
+ }
+ else
+ {
+ uno::Reference< chart2::data::XDataSequence > xSeq(
+ StatisticsHelper::getErrorDataSequenceFromDataSource(
+ xErrorBarSource, bIsPositiveValue, bYError ));
+ bApplyNewRange =
+ ! ( xSeq.is() && aNewRange.equals( xSeq->getSourceRangeRepresentation()));
+ }
+
+ if( bApplyNewRange )
+ StatisticsHelper::setErrorDataSequence(
+ xErrorBarSource, xDataProvider, aNewRange, bIsPositiveValue, bYError );
+ }
+ }
+ break;
+ }
+
+ return bChanged;
+}
+
+void StatisticsItemConverter::FillSpecialItem(
+ sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+ throw( uno::Exception )
+{
+ switch( nWhichId )
+ {
+ case SCHATTR_STAT_AVERAGE:
+ rOutItemSet.Put(
+ SfxBoolItem( nWhichId,
+ RegressionCurveHelper::hasMeanValueLine(
+ uno::Reference< chart2::XRegressionCurveContainer >(
+ GetPropertySet(), uno::UNO_QUERY ))));
+ break;
+
+ case SCHATTR_STAT_KIND_ERROR:
+ {
+ SvxChartKindError eErrorKind = CHERROR_NONE;
+ uno::Reference< beans::XPropertySet > xErrorBarProp(
+ lcl_GetYErrorBar( GetPropertySet()));
+ if( xErrorBarProp.is() )
+ {
+ sal_Int32 nStyle = 0;
+ if( xErrorBarProp->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nStyle )
+ {
+ switch( nStyle )
+ {
+ case ::com::sun::star::chart::ErrorBarStyle::NONE:
+ break;
+ case ::com::sun::star::chart::ErrorBarStyle::VARIANCE:
+ eErrorKind = CHERROR_VARIANT; break;
+ case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION:
+ eErrorKind = CHERROR_SIGMA; break;
+ case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE:
+ eErrorKind = CHERROR_CONST; break;
+ case ::com::sun::star::chart::ErrorBarStyle::RELATIVE:
+ eErrorKind = CHERROR_PERCENT; break;
+ case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN:
+ eErrorKind = CHERROR_BIGERROR; break;
+ case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR:
+ eErrorKind = CHERROR_STDERROR; break;
+ case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA:
+ eErrorKind = CHERROR_RANGE; break;
+ }
+ }
+ }
+ rOutItemSet.Put( SvxChartKindErrorItem( eErrorKind, SCHATTR_STAT_KIND_ERROR ));
+ }
+ break;
+
+ case SCHATTR_STAT_PERCENT:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
+ if( xErrorBarProp.is())
+ {
+ double fPos, fNeg;
+ lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
+ rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_BIGERROR:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
+ if( xErrorBarProp.is())
+ {
+ double fPos, fNeg;
+ lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
+ rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_CONSTPLUS:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
+ if( xErrorBarProp.is())
+ {
+ double fPos, fNeg;
+ lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
+ rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId ));
+ }
+ }
+ break;
+
+ case SCHATTR_STAT_CONSTMINUS:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
+ if( xErrorBarProp.is())
+ {
+ double fPos, fNeg;
+ lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
+ rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId ));
+ }
+ }
+ break;
+
+ case SCHATTR_REGRESSION_TYPE:
+ {
+ SvxChartRegress eRegress = static_cast< SvxChartRegress >(
+ static_cast< sal_Int32 >(
+ RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine(
+ uno::Reference< chart2::XRegressionCurveContainer >(
+ GetPropertySet(), uno::UNO_QUERY ) )));
+ rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE ));
+ }
+ break;
+
+ case SCHATTR_REGRESSION_SHOW_EQUATION:
+ {
+ bool bShowEq = false;
+ uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
+ if( xEqProp.is())
+ xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq;
+ rOutItemSet.Put( SfxBoolItem( nWhichId, bShowEq ));
+ }
+ break;
+
+ case SCHATTR_REGRESSION_SHOW_COEFF:
+ {
+ bool bShowCoeff = false;
+ uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
+ if( xEqProp.is())
+ xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoeff;
+ rOutItemSet.Put( SfxBoolItem( nWhichId, bShowCoeff ));
+ }
+ break;
+
+ case SCHATTR_STAT_INDICATE:
+ {
+ uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
+ SvxChartIndicate eIndicate = CHINDICATE_BOTH;
+ if( xErrorBarProp.is())
+ {
+ bool bShowPos, bShowNeg;
+ lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg );
+
+ if( bShowPos )
+ {
+ if( bShowNeg )
+ eIndicate = CHINDICATE_BOTH;
+ else
+ eIndicate = CHINDICATE_UP;
+ }
+ else
+ {
+ if( bShowNeg )
+ eIndicate = CHINDICATE_DOWN;
+ else
+ eIndicate = CHINDICATE_NONE;
+ }
+ }
+ rOutItemSet.Put( SvxChartIndicateItem( eIndicate, SCHATTR_STAT_INDICATE ));
+ }
+ break;
+
+ case SCHATTR_STAT_RANGE_POS:
+ case SCHATTR_STAT_RANGE_NEG:
+ {
+ uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), uno::UNO_QUERY );
+ if( xErrorBarSource.is())
+ {
+ uno::Reference< chart2::data::XDataSequence > xSeq(
+ StatisticsHelper::getErrorDataSequenceFromDataSource(
+ xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS) /*, true */ /* y */ ));
+ if( xSeq.is())
+ rOutItemSet.Put( SfxStringItem( nWhichId, String( xSeq->getSourceRangeRepresentation())));
+ }
+ }
+ break;
+ }
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx
new file mode 100644
index 000000000000..2dd9d8730055
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx
@@ -0,0 +1,248 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+#include "TitleItemConverter.hxx"
+#include "SchWhichPairs.hxx"
+#include "macros.hxx"
+#include "ItemPropertyMap.hxx"
+#include "GraphicPropertyItemConverter.hxx"
+#include "CharacterPropertyItemConverter.hxx"
+#include "MultipleItemConverter.hxx"
+#include <svl/intitem.hxx>
+#include <rtl/math.hxx>
+
+#include <com/sun/star/chart2/XTitled.hpp>
+
+#include <functional>
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+::comphelper::ItemPropertyMapType & lcl_GetTitlePropertyMap()
+{
+ static ::comphelper::ItemPropertyMapType aTitlePropertyMap(
+ ::comphelper::MakeItemPropertyMap
+ IPM_MAP_ENTRY( SCHATTR_TEXT_STACKED, "StackCharacters", 0 )
+ );
+
+ return aTitlePropertyMap;
+};
+} // anonymous namespace
+
+namespace chart
+{
+namespace wrapper
+{
+
+// ========================================
+
+class FormattedStringsConverter : public ::comphelper::MultipleItemConverter
+{
+public:
+ FormattedStringsConverter(
+ const uno::Sequence< uno::Reference< chart2::XFormattedString > > & aStrings,
+ SfxItemPool & rItemPool,
+ ::std::auto_ptr< awt::Size > pRefSize,
+ const uno::Reference< beans::XPropertySet > & xParentProp );
+ virtual ~FormattedStringsConverter();
+
+protected:
+ virtual const sal_uInt16 * GetWhichPairs() const;
+};
+
+// ----------------------------------------
+
+FormattedStringsConverter::FormattedStringsConverter(
+ const uno::Sequence< uno::Reference< chart2::XFormattedString > > & aStrings,
+ SfxItemPool & rItemPool,
+ ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize,
+ const uno::Reference< beans::XPropertySet > & xParentProp ) :
+ MultipleItemConverter( rItemPool )
+{
+ bool bHasRefSize = (pRefSize.get() && xParentProp.is());
+ for( sal_Int32 i = 0; i < aStrings.getLength(); ++i )
+ {
+ uno::Reference< beans::XPropertySet > xProp( aStrings[ i ], uno::UNO_QUERY );
+ if( xProp.is())
+ {
+ if( bHasRefSize )
+ m_aConverters.push_back( new CharacterPropertyItemConverter(
+ xProp, rItemPool,
+ ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize )),
+ C2U( "ReferencePageSize" ),
+ xParentProp ));
+ else
+ m_aConverters.push_back( new CharacterPropertyItemConverter( xProp, rItemPool ));
+ }
+ }
+}
+
+FormattedStringsConverter::~FormattedStringsConverter()
+{
+}
+
+const sal_uInt16 * FormattedStringsConverter::GetWhichPairs() const
+{
+ return nCharacterPropertyWhichPairs;
+}
+
+// ========================================
+
+TitleItemConverter::TitleItemConverter(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropertySet,
+ SfxItemPool& rItemPool,
+ SdrModel& rDrawModel,
+ const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
+ ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize ) :
+ ItemConverter( rPropertySet, rItemPool )
+{
+ m_aConverters.push_back( new GraphicPropertyItemConverter(
+ rPropertySet, rItemPool, rDrawModel,
+ xNamedPropertyContainerFactory,
+ GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ));
+
+ // CharacterProperties are not at the title but at its contained XFormattedString objects
+ // take the first formatted string in the sequence
+ uno::Reference< chart2::XTitle > xTitle( rPropertySet, uno::UNO_QUERY );
+ if( xTitle.is())
+ {
+ uno::Sequence< uno::Reference< chart2::XFormattedString > > aStringSeq( xTitle->getText());
+ if( aStringSeq.getLength() > 0 )
+ {
+ m_aConverters.push_back(
+ new FormattedStringsConverter( aStringSeq, rItemPool, pRefSize, rPropertySet ));
+ }
+ }
+}
+
+TitleItemConverter::~TitleItemConverter()
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::DeleteItemConverterPtr() );
+}
+
+void TitleItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
+{
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::FillItemSetFunc( rOutItemSet ));
+
+ // own items
+ ItemConverter::FillItemSet( rOutItemSet );
+}
+
+bool TitleItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
+{
+ bool bResult = false;
+
+ ::std::for_each( m_aConverters.begin(), m_aConverters.end(),
+ ::comphelper::ApplyItemSetFunc( rItemSet, bResult ));
+
+ // own items
+ return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
+}
+
+const sal_uInt16 * TitleItemConverter::GetWhichPairs() const
+{
+ // must span all used items!
+ return nTitleWhichPairs;
+}
+
+bool TitleItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
+{
+ ::comphelper::ItemPropertyMapType & rMap( lcl_GetTitlePropertyMap());
+ ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
+
+ if( aIt == rMap.end())
+ return false;
+
+ rOutProperty =(*aIt).second;
+ return true;
+}
+
+
+bool TitleItemConverter::ApplySpecialItem(
+ sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
+ throw( uno::Exception )
+{
+ bool bChanged = false;
+
+ switch( nWhichId )
+ {
+ case SCHATTR_TEXT_DEGREES:
+ {
+ // convert int to double (divided by 100)
+ double fVal = static_cast< double >(
+ static_cast< const SfxInt32Item & >(
+ rItemSet.Get( nWhichId )).GetValue()) / 100.0;
+ double fOldVal = 0.0;
+ bool bPropExisted =
+ ( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fOldVal );
+
+ if( ! bPropExisted ||
+ ( bPropExisted && fOldVal != fVal ))
+ {
+ GetPropertySet()->setPropertyValue( C2U( "TextRotation" ), uno::makeAny( fVal ));
+ bChanged = true;
+ }
+ }
+ break;
+ }
+
+ return bChanged;
+}
+
+void TitleItemConverter::FillSpecialItem(
+ sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
+ throw( uno::Exception )
+{
+ switch( nWhichId )
+ {
+ case SCHATTR_TEXT_DEGREES:
+ {
+ // convert double to int (times 100)
+ double fVal = 0;
+
+ if( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fVal )
+ {
+ rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >(
+ ::rtl::math::round( fVal * 100.0 ) ) ));
+ }
+ }
+ break;
+ }
+}
+
+} // namespace wrapper
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/itemsetwrapper/makefile.mk b/chart2/source/controller/itemsetwrapper/makefile.mk
new file mode 100644
index 000000000000..8f12443c13f6
--- /dev/null
+++ b/chart2/source/controller/itemsetwrapper/makefile.mk
@@ -0,0 +1,60 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ= ..$/..$/..
+PRJINC= $(PRJ)$/source
+PRJNAME= chart2
+TARGET= chcitemsetwrapper
+
+ENABLE_EXCEPTIONS= TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE: settings.mk
+
+# --- export library -------------------------------------------------
+
+#object files to build and link together to lib $(SLB)$/$(TARGET).lib
+SLOFILES= $(SLO)$/ItemConverter.obj \
+ $(SLO)$/AxisItemConverter.obj \
+ $(SLO)$/MultipleItemConverter.obj \
+ $(SLO)$/MultipleChartConverters.obj \
+ $(SLO)$/CharacterPropertyItemConverter.obj \
+ $(SLO)$/SeriesOptionsItemConverter.obj \
+ $(SLO)$/DataPointItemConverter.obj \
+ $(SLO)$/GraphicPropertyItemConverter.obj \
+ $(SLO)$/LegendItemConverter.obj \
+ $(SLO)$/StatisticsItemConverter.obj \
+ $(SLO)$/TitleItemConverter.obj \
+ $(SLO)$/RegressionCurveItemConverter.obj \
+ $(SLO)$/RegressionEquationItemConverter.obj \
+ $(SLO)$/ErrorBarItemConverter.obj
+
+# --- Targets -----------------------------------------------------------------
+
+.INCLUDE: target.mk
+