LCOV - code coverage report
Current view: top level - sc/source/ui/StatisticsDialogs - ChiSquareTestDialog.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 45 2.2 %
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 "ChiSquareTestDialog.hxx"
      30             : 
      31           0 : ScChiSquareTestDialog::ScChiSquareTestDialog(
      32             :                     SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
      33             :                     vcl::Window* pParent, ScViewData* pViewData ) :
      34             :     ScStatisticsInputOutputDialog(
      35             :             pSfxBindings, pChildWindow, pParent, pViewData,
      36           0 :             "ChiSquareTestDialog", "modules/scalc/ui/chisquaretestdialog.ui" )
      37             : {
      38           0 :     SetText(SC_STRLOAD(RID_STATISTICS_DLGS, STR_CHI_SQUARE_TEST));
      39           0 : }
      40             : 
      41           0 : ScChiSquareTestDialog::~ScChiSquareTestDialog()
      42           0 : {}
      43             : 
      44           0 : bool ScChiSquareTestDialog::Close()
      45             : {
      46           0 :     return DoClose(ScChiSquareTestDialogWrapper::GetChildWindowId());
      47             : }
      48             : 
      49           0 : sal_Int16 ScChiSquareTestDialog::GetUndoNameId()
      50             : {
      51           0 :     return STR_CHI_SQUARE_TEST;
      52             : }
      53             : 
      54           0 : ScRange ScChiSquareTestDialog::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 :     aTemplate.autoReplaceRange("%RANGE%", mInputRange);
      61             : 
      62           0 :     aOutput.writeBoldString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_CHI_SQUARE_TEST));
      63           0 :     aOutput.newLine();
      64             : 
      65             :     // Alpha
      66           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_LABEL_ALPHA));
      67           0 :     aOutput.nextColumn();
      68           0 :     aOutput.writeValue(0.05);
      69           0 :     aTemplate.autoReplaceAddress("%ALPHA%", aOutput.current());
      70           0 :     aOutput.newLine();
      71             : 
      72             :     // DF
      73           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_DEGREES_OF_FREEDOM_LABEL));
      74           0 :     aOutput.nextColumn();
      75           0 :     aTemplate.setTemplate("=(COLUMNS(%RANGE%) - 1) * (ROWS(%RANGE%) - 1)");
      76           0 :     aTemplate.autoReplaceAddress("%DEGREES_OF_FREEDOM%", aOutput.current());
      77           0 :     aOutput.writeFormula(aTemplate.getTemplate());
      78           0 :     aOutput.newLine();
      79             : 
      80             :     // p Value
      81           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_P_VALUE_LABEL));
      82           0 :     aOutput.nextColumn();
      83           0 :     aTemplate.setTemplate("=CHITEST(%RANGE%; MMULT(MMULT(%RANGE%;TRANSPOSE(IF(COLUMN(%RANGE%))));MMULT(TRANSPOSE(IF(ROW(%RANGE%)));%RANGE%)) / SUM(%RANGE%))");
      84           0 :     aTemplate.autoReplaceAddress("%P_VALUE%", aOutput.current());
      85           0 :     aOutput.writeFormula(aTemplate.getTemplate());
      86           0 :     aOutput.newLine();
      87             : 
      88             :     // Test Statistic
      89           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_TEST_STATISTIC_LABEL));
      90           0 :     aOutput.nextColumn();
      91           0 :     aTemplate.setTemplate("=CHIINV(%P_VALUE%; %DEGREES_OF_FREEDOM%)");
      92           0 :     aOutput.writeFormula(aTemplate.getTemplate());
      93           0 :     aOutput.newLine();
      94             : 
      95             :     // Critical value
      96           0 :     aOutput.writeString(SC_STRLOAD(RID_STATISTICS_DLGS, STR_CRITICAL_VALUE_LABEL));
      97           0 :     aOutput.nextColumn();
      98           0 :     aTemplate.setTemplate("=CHIINV(%ALPHA%; %DEGREES_OF_FREEDOM%)");
      99           0 :     aOutput.writeFormula(aTemplate.getTemplate());
     100           0 :     aOutput.newLine();
     101             : 
     102           0 :     return ScRange(aOutput.mMinimumAddress, aOutput.mMaximumAddress);
     103         156 : }
     104             : 
     105             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11