LCOV - code coverage report
Current view: top level - sc/source/ui/StatisticsDialogs - FTestDialog.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 115 0.9 %
Date: 2015-06-13 12:38:46 Functions: 2 8 25.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 "docfunc.hxx"
      26             : #include "StatisticsDialogs.hrc"
      27             : #include "TableFillingAndNavigationTools.hxx"
      28             : 
      29             : #include "FTestDialog.hxx"
      30             : 
      31           0 : ScFTestDialog::ScFTestDialog(
      32             :                     SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
      33             :                     vcl::Window* pParent, ScViewData* pViewData ) :
      34             :     ScStatisticsTwoVariableDialog(
      35             :             pSfxBindings, pChildWindow, pParent, pViewData,
      36           0 :             "TTestDialog", "modules/scalc/ui/ttestdialog.ui" )
      37             : {
      38           0 :     SetText(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST));
      39           0 : }
      40             : 
      41           0 : ScFTestDialog::~ScFTestDialog()
      42           0 : {}
      43             : 
      44           0 : bool ScFTestDialog::Close()
      45             : {
      46           0 :     return DoClose( ScFTestDialogWrapper::GetChildWindowId() );
      47             : }
      48             : 
      49           0 : sal_Int16 ScFTestDialog::GetUndoNameId()
      50             : {
      51           0 :     return STR_FTEST_UNDO_NAME;
      52             : }
      53             : 
      54           0 : ScRange ScFTestDialog::ApplyOutput(ScDocShell* pDocShell)
      55             : {
      56             :     AddressWalkerWriter aOutput(mOutputAddress, pDocShell, mDocument,
      57           0 :             formula::FormulaGrammar::mergeToGrammar(formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
      58           0 :     FormulaTemplate aTemplate(mDocument);
      59             : 
      60           0 :     boost::scoped_ptr<DataRangeIterator> pVariable1Iterator;
      61           0 :     if (mGroupedBy == BY_COLUMN)
      62           0 :         pVariable1Iterator.reset(new DataRangeByColumnIterator(mVariable1Range));
      63             :     else
      64           0 :         pVariable1Iterator.reset(new DataRangeByRowIterator(mVariable1Range));
      65             : 
      66           0 :     boost::scoped_ptr<DataRangeIterator> pVariable2Iterator;
      67           0 :     if (mGroupedBy == BY_COLUMN)
      68           0 :         pVariable2Iterator.reset(new DataRangeByColumnIterator(mVariable2Range));
      69             :     else
      70           0 :         pVariable2Iterator.reset(new DataRangeByRowIterator(mVariable2Range));
      71             : 
      72           0 :     aTemplate.autoReplaceRange("%VARIABLE1_RANGE%", pVariable1Iterator->get());
      73           0 :     aTemplate.autoReplaceRange("%VARIABLE2_RANGE%", pVariable2Iterator->get());
      74             : 
      75           0 :     aOutput.writeBoldString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_UNDO_NAME));
      76           0 :     aOutput.newLine();
      77             : 
      78             :     // Alpha
      79           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_LABEL_ALPHA));
      80           0 :     aOutput.nextColumn();
      81           0 :     aOutput.writeValue(0.05);
      82           0 :     aTemplate.autoReplaceAddress("%ALPHA%", aOutput.current());
      83           0 :     aOutput.newLine();
      84             : 
      85           0 :     aOutput.nextColumn();
      86           0 :     aOutput.writeBoldString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_VARIABLE_1_LABEL));
      87           0 :     aOutput.nextColumn();
      88           0 :     aOutput.writeBoldString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_VARIABLE_2_LABEL));
      89           0 :     aOutput.newLine();
      90             : 
      91           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STRID_CALC_MEAN));
      92           0 :     aOutput.nextColumn();
      93           0 :     aTemplate.setTemplate("=AVERAGE(%VARIABLE1_RANGE%)");
      94           0 :     aOutput.writeFormula(aTemplate.getTemplate());
      95           0 :     aOutput.nextColumn();
      96           0 :     aTemplate.setTemplate("=AVERAGE(%VARIABLE2_RANGE%)");
      97           0 :     aOutput.writeFormula(aTemplate.getTemplate());
      98           0 :     aOutput.newLine();
      99             : 
     100           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STRID_CALC_VARIANCE));
     101           0 :     aOutput.nextColumn();
     102           0 :     aTemplate.setTemplate("=VAR(%VARIABLE1_RANGE%)");
     103           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     104           0 :     aTemplate.autoReplaceAddress("%VARIABLE1_VARIANCE%", aOutput.current());
     105           0 :     aOutput.nextColumn();
     106           0 :     aTemplate.setTemplate("=VAR(%VARIABLE2_RANGE%)");
     107           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     108           0 :     aTemplate.autoReplaceAddress("%VARIABLE2_VARIANCE%", aOutput.current());
     109           0 :     aOutput.newLine();
     110             : 
     111           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_OBSERVATIONS_LABEL));
     112           0 :     aOutput.nextColumn();
     113           0 :     aTemplate.setTemplate("=COUNT(%VARIABLE1_RANGE%)");
     114           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     115           0 :     aTemplate.autoReplaceAddress("%VARIABLE1_OBSERVATIONS%", aOutput.current());
     116           0 :     aOutput.nextColumn();
     117           0 :     aTemplate.setTemplate("=COUNT(%VARIABLE2_RANGE%)");
     118           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     119           0 :     aTemplate.autoReplaceAddress("%VARIABLE2_OBSERVATIONS%", aOutput.current());
     120           0 :     aOutput.newLine();
     121             : 
     122           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_ANOVA_LABEL_DF));
     123           0 :     aOutput.nextColumn();
     124           0 :     aTemplate.setTemplate("=%VARIABLE1_OBSERVATIONS% - 1");
     125           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     126           0 :     aTemplate.autoReplaceAddress("%VARIABLE1_DEGREE_OF_FREEDOM%", aOutput.current());
     127           0 :     aOutput.nextColumn();
     128           0 :     aTemplate.setTemplate("=%VARIABLE2_OBSERVATIONS% - 1");
     129           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     130           0 :     aTemplate.autoReplaceAddress("%VARIABLE2_DEGREE_OF_FREEDOM%", aOutput.current());
     131           0 :     aOutput.newLine();
     132             : 
     133           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_ANOVA_LABEL_F));
     134           0 :     aOutput.nextColumn();
     135           0 :     aTemplate.setTemplate("=%VARIABLE1_VARIANCE% / %VARIABLE2_VARIANCE%");
     136           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     137           0 :     aTemplate.autoReplaceAddress("%F_VALUE%", aOutput.current());
     138           0 :     aOutput.newLine();
     139             : 
     140           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_P_RIGHT_TAIL));
     141           0 :     aOutput.nextColumn();
     142           0 :     aTemplate.setTemplate("=FDIST(%F_VALUE%; %VARIABLE1_DEGREE_OF_FREEDOM%; %VARIABLE2_DEGREE_OF_FREEDOM%)");
     143           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     144           0 :     aTemplate.autoReplaceAddress("%P_RIGHT_TAIL_VALUE%", aOutput.current());
     145           0 :     aOutput.newLine();
     146             : 
     147           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_F_CRITICAL_RIGHT_TAIL));
     148           0 :     aOutput.nextColumn();
     149           0 :     aTemplate.setTemplate("=FINV(%ALPHA%; %VARIABLE1_DEGREE_OF_FREEDOM%; %VARIABLE2_DEGREE_OF_FREEDOM%)");
     150           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     151           0 :     aOutput.newLine();
     152             : 
     153           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_P_LEFT_TAIL));
     154           0 :     aOutput.nextColumn();
     155           0 :     aTemplate.setTemplate("=1 - %P_RIGHT_TAIL_VALUE%");
     156           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     157           0 :     aTemplate.autoReplaceAddress("%P_LEFT_TAIL_VALUE%", aOutput.current());
     158           0 :     aOutput.newLine();
     159             : 
     160           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_F_CRITICAL_LEFT_TAIL));
     161           0 :     aOutput.nextColumn();
     162           0 :     aTemplate.setTemplate("=FINV(1-%ALPHA%; %VARIABLE1_DEGREE_OF_FREEDOM%; %VARIABLE2_DEGREE_OF_FREEDOM%)");
     163           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     164           0 :     aOutput.newLine();
     165             : 
     166           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_P_TWO_TAIL));
     167           0 :     aOutput.nextColumn();
     168           0 :     aTemplate.setTemplate("=2*MIN(%P_RIGHT_TAIL_VALUE%; %P_LEFT_TAIL_VALUE%)");
     169           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     170           0 :     aOutput.newLine();
     171             : 
     172           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_FTEST_F_CRITICAL_TWO_TAIL));
     173           0 :     aOutput.nextColumn();
     174           0 :     aTemplate.setTemplate("=FINV(1-(%ALPHA%/2); %VARIABLE1_DEGREE_OF_FREEDOM%; %VARIABLE2_DEGREE_OF_FREEDOM%)");
     175           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     176           0 :     aOutput.nextColumn();
     177           0 :     aTemplate.setTemplate("=FINV(%ALPHA%/2; %VARIABLE1_DEGREE_OF_FREEDOM%; %VARIABLE2_DEGREE_OF_FREEDOM%)");
     178           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     179             : 
     180           0 :     return ScRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress);
     181         156 : }
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11