LCOV - code coverage report
Current view: top level - sc/source/ui/StatisticsDialogs - DescriptiveStatisticsDialog.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 46 0.0 %
Date: 2014-04-14 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  */
      10             : 
      11             : #include <sfx2/dispatch.hxx>
      12             : #include <svl/zforlist.hxx>
      13             : #include <svl/undo.hxx>
      14             : #include <boost/random.hpp>
      15             : #include <boost/scoped_ptr.hpp>
      16             : 
      17             : #include "formulacell.hxx"
      18             : #include "rangelst.hxx"
      19             : #include "scitems.hxx"
      20             : #include "docsh.hxx"
      21             : #include "document.hxx"
      22             : #include "uiitems.hxx"
      23             : #include "reffact.hxx"
      24             : #include "strload.hxx"
      25             : #include "random.hxx"
      26             : #include "docfunc.hxx"
      27             : #include "StatisticsDialogs.hrc"
      28             : #include "TableFillingAndNavigationTools.hxx"
      29             : 
      30             : #include "DescriptiveStatisticsDialog.hxx"
      31             : 
      32             : namespace
      33             : {
      34             : 
      35             : struct StatisticCalculation {
      36             :     sal_Int16   aCalculationNameId;
      37             :     const char* aFormula;
      38             : };
      39             : 
      40             : static const StatisticCalculation lclCalcDefinitions[] =
      41             : {
      42             :     { STRID_CALC_MEAN,           "=AVERAGE(%RANGE%)" },
      43             :     { STRID_CALC_STD_ERROR,      "=SQRT(VAR(%RANGE%)/COUNT(%RANGE%))"},
      44             :     { STRID_CALC_MODE,           "=MODE(%RANGE%)"},
      45             :     { STRID_CALC_MEDIAN,         "=MEDIAN(%RANGE%)"},
      46             :     { STRID_CALC_VARIANCE,       "=VAR(%RANGE%)"},
      47             :     { STRID_CALC_STD_DEVIATION,  "=STDEV(%RANGE%)"},
      48             :     { STRID_CALC_KURTOSIS,       "=KURT(%RANGE%)"},
      49             :     { STRID_CALC_SKEWNESS,       "=SKEW(%RANGE%)"},
      50             :     { STRID_CALC_RANGE,          "=MAX(%RANGE%)-MIN(%RANGE%)"},
      51             :     { STRID_CALC_MIN,            "=MIN(%RANGE%)"},
      52             :     { STRID_CALC_MAX,            "=MAX(%RANGE%)"},
      53             :     { STRID_CALC_SUM,            "=SUM(%RANGE%)"},
      54             :     { STRID_CALC_COUNT,          "=COUNT(%RANGE%)" },
      55             :     { 0,                         NULL }
      56             : };
      57             : 
      58           0 : static const OUString strWildcardRange("%RANGE%");
      59           0 : static const OUString strWildcardNumber("%NUMBER%");
      60             : 
      61             : }
      62             : 
      63           0 : ScDescriptiveStatisticsDialog::ScDescriptiveStatisticsDialog(
      64             :                     SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
      65             :                     Window* pParent, ScViewData* pViewData ) :
      66             :     ScStatisticsInputOutputDialog(
      67             :             pSfxBindings, pChildWindow, pParent, pViewData,
      68           0 :             "DescriptiveStatisticsDialog", "modules/scalc/ui/descriptivestatisticsdialog.ui" )
      69           0 : {}
      70             : 
      71           0 : ScDescriptiveStatisticsDialog::~ScDescriptiveStatisticsDialog()
      72           0 : {}
      73             : 
      74           0 : bool ScDescriptiveStatisticsDialog::Close()
      75             : {
      76           0 :     return DoClose( ScDescriptiveStatisticsDialogWrapper::GetChildWindowId() );
      77             : }
      78             : 
      79           0 : sal_Int16 ScDescriptiveStatisticsDialog::GetUndoNameId()
      80             : {
      81           0 :     return STR_DESCRIPTIVE_STATISTICS_UNDO_NAME;
      82             : }
      83             : 
      84           0 : ScRange ScDescriptiveStatisticsDialog::ApplyOutput(ScDocShell* pDocShell)
      85             : {
      86             :     AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument,
      87           0 :             formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
      88           0 :     FormulaTemplate aTemplate(mDocument, mAddressDetails);
      89             : 
      90           0 :     boost::scoped_ptr<DataRangeIterator> pIterator;
      91           0 :     if (mGroupedBy == BY_COLUMN)
      92           0 :         pIterator.reset(new DataRangeByColumnIterator(mInputRange));
      93             :     else
      94           0 :         pIterator.reset(new DataRangeByRowIterator(mInputRange));
      95             : 
      96           0 :     aOutput.nextColumn();
      97             : 
      98             :     // Write column/row labels
      99           0 :     for( ; pIterator->hasNext(); pIterator->next() )
     100             :     {
     101           0 :         if (mGroupedBy == BY_COLUMN)
     102           0 :             aTemplate.setTemplate(SC_STRLOAD(RID_STATISTICS_DLGS, STR_COLUMN_LABEL_TEMPLATE));
     103             :         else
     104           0 :             aTemplate.setTemplate(SC_STRLOAD(RID_STATISTICS_DLGS, STR_ROW_LABEL_TEMPLATE));
     105             : 
     106           0 :         aTemplate.applyNumber(strWildcardNumber, pIterator->index() + 1);
     107           0 :         aOutput.writeBoldString(aTemplate.getTemplate());
     108           0 :         aOutput.nextColumn();
     109             :     }
     110           0 :     aOutput.nextRow();
     111           0 :     aOutput.resetColumn();
     112           0 :     aOutput.push();
     113             : 
     114             :     // Write calculation labels
     115           0 :     for(sal_Int32 i = 0; lclCalcDefinitions[i].aFormula != NULL; i++)
     116             :     {
     117           0 :         OUString aLabel(SC_STRLOAD(RID_STATISTICS_DLGS, lclCalcDefinitions[i].aCalculationNameId));
     118           0 :         aOutput.writeString(aLabel);
     119           0 :         aOutput.nextRow();
     120           0 :     }
     121           0 :     aOutput.nextColumn();
     122             : 
     123           0 :     pIterator->reset();
     124             : 
     125           0 :     for( ; pIterator->hasNext(); pIterator->next() )
     126             :     {
     127           0 :         aOutput.resetRow();
     128             : 
     129           0 :         for(sal_Int32 i = 0; lclCalcDefinitions[i].aFormula != NULL; i++)
     130             :         {
     131           0 :             aTemplate.setTemplate(lclCalcDefinitions[i].aFormula);
     132           0 :             aTemplate.applyRange(strWildcardRange, pIterator->get());
     133           0 :             aOutput.writeFormula(aTemplate.getTemplate());
     134           0 :             aOutput.nextRow();
     135             :         }
     136           0 :         aOutput.nextColumn();
     137             :     }
     138             : 
     139           0 :     return ScRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress);
     140           0 : }
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10