LCOV - code coverage report
Current view: top level - sc/source/ui/StatisticsDialogs - MatrixComparisonGenerator.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 53 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             : 
      15             : #include "formulacell.hxx"
      16             : #include "rangelst.hxx"
      17             : #include "scitems.hxx"
      18             : #include "docsh.hxx"
      19             : #include "document.hxx"
      20             : #include "uiitems.hxx"
      21             : #include "reffact.hxx"
      22             : #include "strload.hxx"
      23             : #include "random.hxx"
      24             : #include "docfunc.hxx"
      25             : #include "StatisticsDialogs.hrc"
      26             : #include "TableFillingAndNavigationTools.hxx"
      27             : 
      28             : #include "MatrixComparisonGenerator.hxx"
      29             : 
      30             : namespace
      31             : {
      32           0 :     static const OUString strWildcard1("%VAR1%");
      33           0 :     static const OUString strWildcard2("%VAR2%");
      34             : 
      35           0 :     static const OUString strWildcardNumber("%NUMBER%");
      36             : 
      37           0 :     void lclWriteCorrelationFormulas(
      38             :             AddressWalkerWriter& aOutput, FormulaTemplate& aTemplate,
      39             :             ScRangeList aRangeList, const OUString& aTemplateString)
      40             :     {
      41           0 :         for (size_t i = 0; i < aRangeList.size(); i++)
      42             :         {
      43           0 :             aOutput.resetRow();
      44           0 :             for (size_t j = 0; j < aRangeList.size(); j++)
      45             :             {
      46           0 :                 if (j >= i)
      47             :                 {
      48           0 :                     aTemplate.setTemplate(aTemplateString);
      49           0 :                     aTemplate.applyRange(strWildcard1, *aRangeList[i]);
      50           0 :                     aTemplate.applyRange(strWildcard2, *aRangeList[j]);
      51           0 :                     aOutput.writeFormula(aTemplate.getTemplate());
      52             :                 }
      53           0 :                 aOutput.nextRow();
      54             :             }
      55           0 :             aOutput.nextColumn();
      56             :         }
      57           0 :     }
      58             : }
      59             : 
      60           0 : ScMatrixComparisonGenerator::ScMatrixComparisonGenerator(
      61             :                                     SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
      62             :                                     Window* pParent, ScViewData* pViewData, const OString& rID,
      63             :                                     const OUString& rUiXmlDescription) :
      64           0 :     ScStatisticsInputOutputDialog(pSfxBindings, pChildWindow, pParent, pViewData, rID, rUiXmlDescription)
      65           0 : {}
      66             : 
      67           0 : ScMatrixComparisonGenerator::~ScMatrixComparisonGenerator()
      68           0 : {}
      69             : 
      70           0 : sal_Int16 ScMatrixComparisonGenerator::GetUndoNameId()
      71             : {
      72           0 :     return STR_CORRELATION_UNDO_NAME;
      73             : }
      74             : 
      75           0 : ScRange ScMatrixComparisonGenerator::ApplyOutput(ScDocShell* pDocShell)
      76             : {
      77             :     AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument,
      78           0 :             formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
      79           0 :     FormulaTemplate aTemplate(mDocument, mAddressDetails);
      80             : 
      81           0 :     SCTAB inTab = mInputRange.aStart.Tab();
      82             : 
      83           0 :     ScRangeList aRangeList;
      84             : 
      85           0 :     if (mGroupedBy == BY_COLUMN)
      86           0 :         aRangeList = MakeColumnRangeList(inTab, mInputRange.aStart, mInputRange.aEnd);
      87             :     else
      88           0 :         aRangeList = MakeRowRangeList(inTab, mInputRange.aStart, mInputRange.aEnd);
      89             : 
      90             :     // labels
      91           0 :     output.writeString(getLabel());
      92           0 :     output.nextColumn();
      93             : 
      94             :     // write labels to columns
      95           0 :     for (size_t i = 0; i < aRangeList.size(); i++)
      96             :     {
      97           0 :         if (mGroupedBy == BY_COLUMN)
      98           0 :             aTemplate.setTemplate(SC_STRLOAD(RID_STATISTICS_DLGS, STR_COLUMN_LABEL_TEMPLATE));
      99             :         else
     100           0 :             aTemplate.setTemplate(SC_STRLOAD(RID_STATISTICS_DLGS, STR_ROW_LABEL_TEMPLATE));
     101             : 
     102           0 :         aTemplate.applyNumber(strWildcardNumber, i + 1);
     103           0 :         output.writeString(aTemplate.getTemplate());
     104           0 :         output.nextColumn();
     105             :     }
     106             : 
     107             :     // write labels to rows
     108           0 :     output.resetColumn();
     109           0 :     output.nextRow();
     110           0 :     for (size_t i = 0; i < aRangeList.size(); i++)
     111             :     {
     112           0 :         if (mGroupedBy == BY_COLUMN)
     113           0 :             aTemplate.setTemplate(SC_STRLOAD(RID_STATISTICS_DLGS, STR_COLUMN_LABEL_TEMPLATE));
     114             :         else
     115           0 :             aTemplate.setTemplate(SC_STRLOAD(RID_STATISTICS_DLGS, STR_ROW_LABEL_TEMPLATE));
     116             : 
     117           0 :         aTemplate.applyNumber(strWildcardNumber, i + 1);
     118           0 :         output.writeString(aTemplate.getTemplate());
     119           0 :         output.nextRow();
     120             :     }
     121             : 
     122             :     // write correlation formulas
     123           0 :     output.reset();
     124           0 :     output.push(1, 1);
     125             : 
     126           0 :     lclWriteCorrelationFormulas(output, aTemplate, aRangeList, getTemplate());
     127             : 
     128           0 :     return ScRange(output.mMinimumAddress, output.mMaximumAddress);
     129           0 : }
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10