1cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5cde9e8dcSAndrew Rist * distributed with this work for additional information
6cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10cde9e8dcSAndrew Rist *
11cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cde9e8dcSAndrew Rist *
13cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18cde9e8dcSAndrew Rist * under the License.
19cde9e8dcSAndrew Rist *
20cde9e8dcSAndrew Rist *************************************************************/
21cde9e8dcSAndrew Rist
22cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir #include "ErrorBarItemConverter.hxx"
27cdf0e10cSrcweir #include "SchWhichPairs.hxx"
28cdf0e10cSrcweir #include "macros.hxx"
29cdf0e10cSrcweir #include "ItemPropertyMap.hxx"
30cdf0e10cSrcweir #include "ErrorBar.hxx"
31cdf0e10cSrcweir #include "PropertyHelper.hxx"
32cdf0e10cSrcweir #include "ChartModelHelper.hxx"
33cdf0e10cSrcweir #include "ChartTypeHelper.hxx"
34cdf0e10cSrcweir #include "StatisticsHelper.hxx"
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include "GraphicPropertyItemConverter.hxx"
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <svl/stritem.hxx>
39cdf0e10cSrcweir #include <svx/chrtitem.hxx>
40cdf0e10cSrcweir #include <svl/intitem.hxx>
41cdf0e10cSrcweir #include <rtl/math.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir #include <com/sun/star/chart2/DataPointLabel.hpp>
44cdf0e10cSrcweir #include <com/sun/star/chart2/XInternalDataProvider.hpp>
45cdf0e10cSrcweir #include <com/sun/star/chart/ErrorBarStyle.hpp>
46cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp>
47cdf0e10cSrcweir
48cdf0e10cSrcweir #include <functional>
49cdf0e10cSrcweir #include <algorithm>
50cdf0e10cSrcweir #include <vector>
51cdf0e10cSrcweir
52cdf0e10cSrcweir using namespace ::com::sun::star;
53cdf0e10cSrcweir
54cdf0e10cSrcweir namespace
55cdf0e10cSrcweir {
56cdf0e10cSrcweir
lcl_getErrorValues(const uno::Reference<beans::XPropertySet> & xErrorBarProp,double & rOutPosError,double & rOutNegError)57cdf0e10cSrcweir void lcl_getErrorValues( const uno::Reference< beans::XPropertySet > & xErrorBarProp,
58cdf0e10cSrcweir double & rOutPosError, double & rOutNegError )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir if( ! xErrorBarProp.is())
61cdf0e10cSrcweir return;
62cdf0e10cSrcweir
63cdf0e10cSrcweir try
64cdf0e10cSrcweir {
65cdf0e10cSrcweir xErrorBarProp->getPropertyValue( C2U( "PositiveError" )) >>= rOutPosError;
66cdf0e10cSrcweir xErrorBarProp->getPropertyValue( C2U( "NegativeError" )) >>= rOutNegError;
67cdf0e10cSrcweir }
68cdf0e10cSrcweir catch( uno::Exception & ex )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
71cdf0e10cSrcweir }
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
lcl_getErrorIndicatorValues(const uno::Reference<beans::XPropertySet> & xErrorBarProp,bool & rOutShowPosError,bool & rOutShowNegError)74cdf0e10cSrcweir void lcl_getErrorIndicatorValues(
75cdf0e10cSrcweir const uno::Reference< beans::XPropertySet > & xErrorBarProp,
76cdf0e10cSrcweir bool & rOutShowPosError, bool & rOutShowNegError )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir if( ! xErrorBarProp.is())
79cdf0e10cSrcweir return;
80cdf0e10cSrcweir
81cdf0e10cSrcweir try
82cdf0e10cSrcweir {
83cdf0e10cSrcweir xErrorBarProp->getPropertyValue( C2U( "ShowPositiveError" )) >>= rOutShowPosError;
84cdf0e10cSrcweir xErrorBarProp->getPropertyValue( C2U( "ShowNegativeError" )) >>= rOutShowNegError;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir catch( uno::Exception & ex )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
89cdf0e10cSrcweir }
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir } // anonymous namespace
93cdf0e10cSrcweir
94cdf0e10cSrcweir namespace chart
95cdf0e10cSrcweir {
96cdf0e10cSrcweir namespace wrapper
97cdf0e10cSrcweir {
98cdf0e10cSrcweir
ErrorBarItemConverter(const uno::Reference<frame::XModel> & xModel,const uno::Reference<beans::XPropertySet> & rPropertySet,SfxItemPool & rItemPool,SdrModel & rDrawModel,const uno::Reference<lang::XMultiServiceFactory> & xNamedPropertyContainerFactory)99cdf0e10cSrcweir ErrorBarItemConverter::ErrorBarItemConverter(
100cdf0e10cSrcweir const uno::Reference< frame::XModel > & xModel,
101cdf0e10cSrcweir const uno::Reference< beans::XPropertySet > & rPropertySet,
102cdf0e10cSrcweir SfxItemPool& rItemPool,
103cdf0e10cSrcweir SdrModel& rDrawModel,
104cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) :
105cdf0e10cSrcweir ItemConverter( rPropertySet, rItemPool ),
106cdf0e10cSrcweir m_spGraphicConverter( new GraphicPropertyItemConverter(
107cdf0e10cSrcweir rPropertySet, rItemPool, rDrawModel,
108cdf0e10cSrcweir xNamedPropertyContainerFactory,
109cdf0e10cSrcweir GraphicPropertyItemConverter::LINE_PROPERTIES )),
110cdf0e10cSrcweir m_xModel( xModel )
111cdf0e10cSrcweir {}
112cdf0e10cSrcweir
~ErrorBarItemConverter()113cdf0e10cSrcweir ErrorBarItemConverter::~ErrorBarItemConverter()
114cdf0e10cSrcweir {}
115cdf0e10cSrcweir
FillItemSet(SfxItemSet & rOutItemSet) const116cdf0e10cSrcweir void ErrorBarItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
117cdf0e10cSrcweir {
118cdf0e10cSrcweir m_spGraphicConverter->FillItemSet( rOutItemSet );
119cdf0e10cSrcweir
120cdf0e10cSrcweir // own items
121cdf0e10cSrcweir ItemConverter::FillItemSet( rOutItemSet );
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
ApplyItemSet(const SfxItemSet & rItemSet)124cdf0e10cSrcweir bool ErrorBarItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir bool bResult = m_spGraphicConverter->ApplyItemSet( rItemSet );
127cdf0e10cSrcweir
128cdf0e10cSrcweir // own items
129cdf0e10cSrcweir return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
130cdf0e10cSrcweir }
131cdf0e10cSrcweir
GetWhichPairs() const132cdf0e10cSrcweir const sal_uInt16 * ErrorBarItemConverter::GetWhichPairs() const
133cdf0e10cSrcweir {
134cdf0e10cSrcweir // must span all used items!
135cdf0e10cSrcweir return nErrorBarWhichPairs;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
GetItemProperty(tWhichIdType,tPropertyNameWithMemberId &) const138cdf0e10cSrcweir bool ErrorBarItemConverter::GetItemProperty(
139cdf0e10cSrcweir tWhichIdType /* nWhichId */,
140cdf0e10cSrcweir tPropertyNameWithMemberId & /* rOutProperty */ ) const
141cdf0e10cSrcweir {
142cdf0e10cSrcweir return false;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
ApplySpecialItem(sal_uInt16 nWhichId,const SfxItemSet & rItemSet)145cdf0e10cSrcweir bool ErrorBarItemConverter::ApplySpecialItem(
146cdf0e10cSrcweir sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
147cdf0e10cSrcweir throw( uno::Exception )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir bool bChanged = false;
150cdf0e10cSrcweir uno::Any aValue;
151cdf0e10cSrcweir
152cdf0e10cSrcweir switch( nWhichId )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT,
155cdf0e10cSrcweir // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS,
156cdf0e10cSrcweir // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE
157cdf0e10cSrcweir case SCHATTR_STAT_KIND_ERROR:
158cdf0e10cSrcweir {
159cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet());
160cdf0e10cSrcweir
161cdf0e10cSrcweir SvxChartKindError eErrorKind =
162cdf0e10cSrcweir static_cast< const SvxChartKindErrorItem & >(
163cdf0e10cSrcweir rItemSet.Get( nWhichId )).GetValue();
164cdf0e10cSrcweir
165cdf0e10cSrcweir if( !xErrorBarProp.is() && eErrorKind == CHERROR_NONE)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir //nothing to do
168cdf0e10cSrcweir }
169cdf0e10cSrcweir else
170cdf0e10cSrcweir {
171cdf0e10cSrcweir sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
172cdf0e10cSrcweir
173cdf0e10cSrcweir switch( eErrorKind )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir case CHERROR_NONE:
176cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; break;
177cdf0e10cSrcweir case CHERROR_VARIANT:
178cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::VARIANCE; break;
179cdf0e10cSrcweir case CHERROR_SIGMA:
180cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION; break;
181cdf0e10cSrcweir case CHERROR_PERCENT:
182cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE; break;
183cdf0e10cSrcweir case CHERROR_BIGERROR:
184cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN; break;
185cdf0e10cSrcweir case CHERROR_CONST:
186cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE; break;
187cdf0e10cSrcweir case CHERROR_STDERROR:
188cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR; break;
189cdf0e10cSrcweir case CHERROR_RANGE:
190cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::FROM_DATA; break;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir
193cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "ErrorBarStyle" ),
194cdf0e10cSrcweir uno::makeAny( nStyle ));
195cdf0e10cSrcweir bChanged = true;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir }
198cdf0e10cSrcweir break;
199cdf0e10cSrcweir
200cdf0e10cSrcweir case SCHATTR_STAT_PERCENT:
201cdf0e10cSrcweir case SCHATTR_STAT_BIGERROR:
202cdf0e10cSrcweir {
203cdf0e10cSrcweir OSL_ENSURE( false, "Deprectaed item" );
204cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet());
205cdf0e10cSrcweir
206cdf0e10cSrcweir double fValue =
207cdf0e10cSrcweir static_cast< const SvxDoubleItem & >(
208cdf0e10cSrcweir rItemSet.Get( nWhichId )).GetValue();
209cdf0e10cSrcweir double fPos, fNeg;
210cdf0e10cSrcweir lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
211cdf0e10cSrcweir
212cdf0e10cSrcweir if( ! ( ::rtl::math::approxEqual( fPos, fValue ) &&
213cdf0e10cSrcweir ::rtl::math::approxEqual( fNeg, fValue )))
214cdf0e10cSrcweir {
215cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "PositiveError" ),
216cdf0e10cSrcweir uno::makeAny( fValue ));
217cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "NegativeError" ),
218cdf0e10cSrcweir uno::makeAny( fValue ));
219cdf0e10cSrcweir bChanged = true;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir }
222cdf0e10cSrcweir break;
223cdf0e10cSrcweir
224cdf0e10cSrcweir case SCHATTR_STAT_CONSTPLUS:
225cdf0e10cSrcweir {
226cdf0e10cSrcweir double fValue =
227cdf0e10cSrcweir static_cast< const SvxDoubleItem & >(
228cdf0e10cSrcweir rItemSet.Get( nWhichId )).GetValue();
229cdf0e10cSrcweir double fPos, fNeg;
230cdf0e10cSrcweir lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
231cdf0e10cSrcweir
232cdf0e10cSrcweir if( ! ::rtl::math::approxEqual( fPos, fValue ))
233cdf0e10cSrcweir {
234cdf0e10cSrcweir GetPropertySet()->setPropertyValue( C2U( "PositiveError" ), uno::makeAny( fValue ));
235cdf0e10cSrcweir bChanged = true;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir }
238cdf0e10cSrcweir break;
239cdf0e10cSrcweir
240cdf0e10cSrcweir case SCHATTR_STAT_CONSTMINUS:
241cdf0e10cSrcweir {
242cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet());
243cdf0e10cSrcweir
244cdf0e10cSrcweir double fValue =
245cdf0e10cSrcweir static_cast< const SvxDoubleItem & >(
246cdf0e10cSrcweir rItemSet.Get( nWhichId )).GetValue();
247cdf0e10cSrcweir double fPos, fNeg;
248cdf0e10cSrcweir lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
249cdf0e10cSrcweir
250cdf0e10cSrcweir if( ! ::rtl::math::approxEqual( fNeg, fValue ))
251cdf0e10cSrcweir {
252cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), uno::makeAny( fValue ));
253cdf0e10cSrcweir bChanged = true;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir }
256cdf0e10cSrcweir break;
257cdf0e10cSrcweir
258cdf0e10cSrcweir case SCHATTR_STAT_INDICATE:
259cdf0e10cSrcweir {
260cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet());
261cdf0e10cSrcweir
262cdf0e10cSrcweir SvxChartIndicate eIndicate =
263cdf0e10cSrcweir static_cast< const SvxChartIndicateItem & >(
264cdf0e10cSrcweir rItemSet.Get( nWhichId )).GetValue();
265cdf0e10cSrcweir
266cdf0e10cSrcweir bool bNewIndPos = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_UP );
267cdf0e10cSrcweir bool bNewIndNeg = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_DOWN );
268cdf0e10cSrcweir
269cdf0e10cSrcweir bool bShowPos, bShowNeg;
270cdf0e10cSrcweir lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg );
271cdf0e10cSrcweir
272cdf0e10cSrcweir if( ( bShowPos != bNewIndPos ||
273cdf0e10cSrcweir bShowNeg != bNewIndNeg ))
274cdf0e10cSrcweir {
275cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "ShowPositiveError" ), uno::makeAny( bNewIndPos ));
276cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "ShowNegativeError" ), uno::makeAny( bNewIndNeg ));
277cdf0e10cSrcweir bChanged = true;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir }
280cdf0e10cSrcweir break;
281cdf0e10cSrcweir
282cdf0e10cSrcweir case SCHATTR_STAT_RANGE_POS:
283cdf0e10cSrcweir case SCHATTR_STAT_RANGE_NEG:
284cdf0e10cSrcweir {
285cdf0e10cSrcweir // @todo: also be able to deal with x-error bars
286cdf0e10cSrcweir const bool bYError = true;
287cdf0e10cSrcweir uno::Reference< chart2::data::XDataSource > xErrorBarSource( GetPropertySet(), uno::UNO_QUERY );
288cdf0e10cSrcweir uno::Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY );
289cdf0e10cSrcweir uno::Reference< chart2::data::XDataProvider > xDataProvider;
290cdf0e10cSrcweir
291cdf0e10cSrcweir if( xChartDoc.is())
292cdf0e10cSrcweir xDataProvider.set( xChartDoc->getDataProvider());
293cdf0e10cSrcweir if( xErrorBarSource.is() && xDataProvider.is())
294cdf0e10cSrcweir {
295cdf0e10cSrcweir ::rtl::OUString aNewRange( static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue());
296cdf0e10cSrcweir bool bApplyNewRange = false;
297cdf0e10cSrcweir
298cdf0e10cSrcweir bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS );
299cdf0e10cSrcweir if( xChartDoc->hasInternalDataProvider())
300cdf0e10cSrcweir {
301*9ec58d04SHerbert Dürr if( !aNewRange.isEmpty() )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir uno::Reference< chart2::data::XDataSequence > xSeq(
304cdf0e10cSrcweir StatisticsHelper::getErrorDataSequenceFromDataSource(
305cdf0e10cSrcweir xErrorBarSource, bIsPositiveValue, bYError ));
306cdf0e10cSrcweir if( ! xSeq.is())
307cdf0e10cSrcweir {
308cdf0e10cSrcweir // no data range for error bars yet => create
309cdf0e10cSrcweir uno::Reference< chart2::XInternalDataProvider > xIntDataProvider( xDataProvider, uno::UNO_QUERY );
310cdf0e10cSrcweir OSL_ASSERT( xIntDataProvider.is());
311cdf0e10cSrcweir if( xIntDataProvider.is())
312cdf0e10cSrcweir {
313cdf0e10cSrcweir xIntDataProvider->appendSequence();
314cdf0e10cSrcweir aNewRange = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("last"));
315cdf0e10cSrcweir bApplyNewRange = true;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir }
318cdf0e10cSrcweir }
319cdf0e10cSrcweir }
320cdf0e10cSrcweir else
321cdf0e10cSrcweir {
322cdf0e10cSrcweir uno::Reference< chart2::data::XDataSequence > xSeq(
323cdf0e10cSrcweir StatisticsHelper::getErrorDataSequenceFromDataSource(
324cdf0e10cSrcweir xErrorBarSource, bIsPositiveValue, bYError ));
325cdf0e10cSrcweir bApplyNewRange =
326cdf0e10cSrcweir ! ( xSeq.is() && aNewRange.equals( xSeq->getSourceRangeRepresentation()));
327cdf0e10cSrcweir }
328cdf0e10cSrcweir
329cdf0e10cSrcweir if( bApplyNewRange )
330cdf0e10cSrcweir StatisticsHelper::setErrorDataSequence(
331cdf0e10cSrcweir xErrorBarSource, xDataProvider, aNewRange, bIsPositiveValue, bYError );
332cdf0e10cSrcweir }
333cdf0e10cSrcweir }
334cdf0e10cSrcweir break;
335cdf0e10cSrcweir }
336cdf0e10cSrcweir
337cdf0e10cSrcweir return bChanged;
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
FillSpecialItem(sal_uInt16 nWhichId,SfxItemSet & rOutItemSet) const340cdf0e10cSrcweir void ErrorBarItemConverter::FillSpecialItem(
341cdf0e10cSrcweir sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
342cdf0e10cSrcweir throw( uno::Exception )
343cdf0e10cSrcweir {
344cdf0e10cSrcweir switch( nWhichId )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir case SCHATTR_STAT_KIND_ERROR:
347cdf0e10cSrcweir {
348cdf0e10cSrcweir SvxChartKindError eErrorKind = CHERROR_NONE;
349cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet());
350cdf0e10cSrcweir
351cdf0e10cSrcweir sal_Int32 nStyle = 0;
352cdf0e10cSrcweir if( xErrorBarProp->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nStyle )
353cdf0e10cSrcweir {
354cdf0e10cSrcweir switch( nStyle )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::NONE:
357cdf0e10cSrcweir break;
358cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::VARIANCE:
359cdf0e10cSrcweir eErrorKind = CHERROR_VARIANT; break;
360cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION:
361cdf0e10cSrcweir eErrorKind = CHERROR_SIGMA; break;
362cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE:
363cdf0e10cSrcweir eErrorKind = CHERROR_CONST; break;
364cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::RELATIVE:
365cdf0e10cSrcweir eErrorKind = CHERROR_PERCENT; break;
366cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN:
367cdf0e10cSrcweir eErrorKind = CHERROR_BIGERROR; break;
368cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR:
369cdf0e10cSrcweir eErrorKind = CHERROR_STDERROR; break;
370cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA:
371cdf0e10cSrcweir eErrorKind = CHERROR_RANGE; break;
372cdf0e10cSrcweir }
373cdf0e10cSrcweir }
374cdf0e10cSrcweir rOutItemSet.Put( SvxChartKindErrorItem( eErrorKind, SCHATTR_STAT_KIND_ERROR ));
375cdf0e10cSrcweir }
376cdf0e10cSrcweir break;
377cdf0e10cSrcweir
378cdf0e10cSrcweir case SCHATTR_STAT_PERCENT:
379cdf0e10cSrcweir {
380cdf0e10cSrcweir double fPos, fNeg;
381cdf0e10cSrcweir lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
382cdf0e10cSrcweir rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
383cdf0e10cSrcweir }
384cdf0e10cSrcweir break;
385cdf0e10cSrcweir
386cdf0e10cSrcweir case SCHATTR_STAT_BIGERROR:
387cdf0e10cSrcweir {
388cdf0e10cSrcweir double fPos, fNeg;
389cdf0e10cSrcweir lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
390cdf0e10cSrcweir rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
391cdf0e10cSrcweir }
392cdf0e10cSrcweir break;
393cdf0e10cSrcweir
394cdf0e10cSrcweir case SCHATTR_STAT_CONSTPLUS:
395cdf0e10cSrcweir {
396cdf0e10cSrcweir double fPos, fNeg;
397cdf0e10cSrcweir lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
398cdf0e10cSrcweir rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId ));
399cdf0e10cSrcweir }
400cdf0e10cSrcweir break;
401cdf0e10cSrcweir
402cdf0e10cSrcweir case SCHATTR_STAT_CONSTMINUS:
403cdf0e10cSrcweir {
404cdf0e10cSrcweir double fPos, fNeg;
405cdf0e10cSrcweir lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
406cdf0e10cSrcweir rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId ));
407cdf0e10cSrcweir }
408cdf0e10cSrcweir break;
409cdf0e10cSrcweir
410cdf0e10cSrcweir case SCHATTR_STAT_INDICATE:
411cdf0e10cSrcweir {
412cdf0e10cSrcweir SvxChartIndicate eIndicate = CHINDICATE_BOTH;
413cdf0e10cSrcweir bool bShowPos, bShowNeg;
414cdf0e10cSrcweir lcl_getErrorIndicatorValues( GetPropertySet(), bShowPos, bShowNeg );
415cdf0e10cSrcweir
416cdf0e10cSrcweir if( bShowPos )
417cdf0e10cSrcweir {
418cdf0e10cSrcweir if( bShowNeg )
419cdf0e10cSrcweir eIndicate = CHINDICATE_BOTH;
420cdf0e10cSrcweir else
421cdf0e10cSrcweir eIndicate = CHINDICATE_UP;
422cdf0e10cSrcweir }
423cdf0e10cSrcweir else
424cdf0e10cSrcweir {
425cdf0e10cSrcweir if( bShowNeg )
426cdf0e10cSrcweir eIndicate = CHINDICATE_DOWN;
427cdf0e10cSrcweir else
428cdf0e10cSrcweir eIndicate = CHINDICATE_NONE;
429cdf0e10cSrcweir }
430cdf0e10cSrcweir rOutItemSet.Put( SvxChartIndicateItem( eIndicate, SCHATTR_STAT_INDICATE ));
431cdf0e10cSrcweir }
432cdf0e10cSrcweir break;
433cdf0e10cSrcweir
434cdf0e10cSrcweir case SCHATTR_STAT_RANGE_POS:
435cdf0e10cSrcweir case SCHATTR_STAT_RANGE_NEG:
436cdf0e10cSrcweir {
437cdf0e10cSrcweir uno::Reference< chart2::data::XDataSource > xErrorBarSource( GetPropertySet(), uno::UNO_QUERY );
438cdf0e10cSrcweir if( xErrorBarSource.is())
439cdf0e10cSrcweir {
440cdf0e10cSrcweir uno::Reference< chart2::data::XDataSequence > xSeq(
441cdf0e10cSrcweir StatisticsHelper::getErrorDataSequenceFromDataSource(
442cdf0e10cSrcweir xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS) /*, true */ /* y */ ));
443cdf0e10cSrcweir if( xSeq.is())
444cdf0e10cSrcweir rOutItemSet.Put( SfxStringItem( nWhichId, String( xSeq->getSourceRangeRepresentation())));
445cdf0e10cSrcweir }
446cdf0e10cSrcweir }
447cdf0e10cSrcweir break;
448cdf0e10cSrcweir }
449cdf0e10cSrcweir }
450cdf0e10cSrcweir
451cdf0e10cSrcweir } // namespace wrapper
452cdf0e10cSrcweir } // namespace chart
453