1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef CHART2_STATISTICSHELPER_HXX 28 #define CHART2_STATISTICSHELPER_HXX 29 30 #include <com/sun/star/uno/Sequence.hxx> 31 #include <com/sun/star/uno/XComponentContext.hpp> 32 #include <com/sun/star/chart2/data/XDataSource.hpp> 33 #include <com/sun/star/chart2/data/XDataProvider.hpp> 34 #include <com/sun/star/chart2/XDataSeries.hpp> 35 #include "charttoolsdllapi.hxx" 36 37 namespace chart 38 { 39 40 class OOO_DLLPUBLIC_CHARTTOOLS StatisticsHelper 41 { 42 public: 43 /** Calculates 1/n * sum (x_i - x_mean)^2. 44 45 @see http://mathworld.wolfram.com/Variance.html 46 47 @param bUnbiasedEstimator 48 If true, 1/(n-1) * sum (x_i - x_mean)^2 is returned. 49 */ 50 static double getVariance( const ::com::sun::star::uno::Sequence< double > & rData, 51 bool bUnbiasedEstimator = false ); 52 53 // square root of the variance 54 static double getStandardDeviation( const ::com::sun::star::uno::Sequence< double > & rData ); 55 56 // also called "Standard deviation of the mean (SDOM)" 57 static double getStandardError( const ::com::sun::star::uno::Sequence< double > & rData ); 58 59 static ::com::sun::star::uno::Reference< 60 ::com::sun::star::chart2::data::XLabeledDataSequence > 61 getErrorLabeledDataSequenceFromDataSource( 62 const ::com::sun::star::uno::Reference< 63 ::com::sun::star::chart2::data::XDataSource > & xDataSource, 64 bool bPositiveValue, 65 bool bYError = true ); 66 67 static ::com::sun::star::uno::Reference< 68 ::com::sun::star::chart2::data::XDataSequence > 69 getErrorDataSequenceFromDataSource( 70 const ::com::sun::star::uno::Reference< 71 ::com::sun::star::chart2::data::XDataSource > & xDataSource, 72 bool bPositiveValue, 73 bool bYError = true ); 74 75 static double getErrorFromDataSource( 76 const ::com::sun::star::uno::Reference< 77 ::com::sun::star::chart2::data::XDataSource > & xDataSource, 78 sal_Int32 nIndex, 79 bool bPositiveValue, 80 bool bYError = true ); 81 82 static void setErrorDataSequence( 83 const ::com::sun::star::uno::Reference< 84 ::com::sun::star::chart2::data::XDataSource > & xDataSource, 85 const ::com::sun::star::uno::Reference< 86 ::com::sun::star::chart2::data::XDataProvider > & xDataProvider, 87 const ::rtl::OUString & rNewRange, 88 bool bPositiveValue, 89 bool bYError = true, 90 ::rtl::OUString * pXMLRange = 0 ); 91 92 /// @return the newly created or existing error bar object 93 static ::com::sun::star::uno::Reference< 94 ::com::sun::star::beans::XPropertySet > 95 addErrorBars( 96 const ::com::sun::star::uno::Reference< 97 ::com::sun::star::chart2::XDataSeries > & xDataSeries, 98 const ::com::sun::star::uno::Reference< 99 ::com::sun::star::uno::XComponentContext > & xContext, 100 sal_Int32 nStyle, 101 bool bYError = true ); 102 103 static ::com::sun::star::uno::Reference< 104 ::com::sun::star::beans::XPropertySet > 105 getErrorBars( 106 const ::com::sun::star::uno::Reference< 107 ::com::sun::star::chart2::XDataSeries > & xDataSeries, 108 bool bYError = true ); 109 110 static bool hasErrorBars( 111 const ::com::sun::star::uno::Reference< 112 ::com::sun::star::chart2::XDataSeries > & xDataSeries, 113 bool bYError = true ); 114 115 static void removeErrorBars( 116 const ::com::sun::star::uno::Reference< 117 ::com::sun::star::chart2::XDataSeries > & xDataSeries, 118 bool bYError = true ); 119 120 static bool usesErrorBarRanges( 121 const ::com::sun::star::uno::Reference< 122 ::com::sun::star::chart2::XDataSeries > & xDataSeries, 123 bool bYError = true ); 124 125 private: 126 // not implemented 127 StatisticsHelper(); 128 }; 129 130 } // namespace chart 131 132 // CHART2_STATISTICSHELPER_HXX 133 #endif 134