fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / StatisticsDialogs / MatrixComparisonGenerator.cxx
blob6bef1fd8030debb0558f3b6749d28d2ca4848f7b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 */
11 #include <sfx2/dispatch.hxx>
12 #include <svl/zforlist.hxx>
13 #include <svl/undo.hxx>
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 "docfunc.hxx"
24 #include "StatisticsDialogs.hrc"
25 #include "TableFillingAndNavigationTools.hxx"
27 #include "MatrixComparisonGenerator.hxx"
29 namespace
31 void lclWriteCorrelationFormulas(
32 AddressWalkerWriter& aOutput, FormulaTemplate& aTemplate,
33 const ScRangeList& aRangeList, const OUString& aTemplateString)
35 for (size_t i = 0; i < aRangeList.size(); i++)
37 aOutput.resetRow();
38 for (size_t j = 0; j < aRangeList.size(); j++)
40 if (j >= i)
42 aTemplate.setTemplate(aTemplateString);
43 aTemplate.applyRange("%VAR1%", *aRangeList[i]);
44 aTemplate.applyRange("%VAR2%", *aRangeList[j]);
45 aOutput.writeFormula(aTemplate.getTemplate());
47 aOutput.nextRow();
49 aOutput.nextColumn();
54 ScMatrixComparisonGenerator::ScMatrixComparisonGenerator(
55 SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow,
56 vcl::Window* pParent, ScViewData* pViewData, const OUString& rID,
57 const OUString& rUiXmlDescription) :
58 ScStatisticsInputOutputDialog(pSfxBindings, pChildWindow, pParent, pViewData, rID, rUiXmlDescription)
61 ScMatrixComparisonGenerator::~ScMatrixComparisonGenerator()
64 sal_Int16 ScMatrixComparisonGenerator::GetUndoNameId()
66 return STR_CORRELATION_UNDO_NAME;
69 ScRange ScMatrixComparisonGenerator::ApplyOutput(ScDocShell* pDocShell)
71 AddressWalkerWriter output(mOutputAddress, pDocShell, mDocument,
72 formula::FormulaGrammar::mergeToGrammar( formula::FormulaGrammar::GRAM_ENGLISH, mAddressDetails.eConv));
73 FormulaTemplate aTemplate(mDocument);
75 SCTAB inTab = mInputRange.aStart.Tab();
77 ScRangeList aRangeList;
79 if (mGroupedBy == BY_COLUMN)
80 aRangeList = MakeColumnRangeList(inTab, mInputRange.aStart, mInputRange.aEnd);
81 else
82 aRangeList = MakeRowRangeList(inTab, mInputRange.aStart, mInputRange.aEnd);
84 // labels
85 output.writeString(getLabel());
86 output.nextColumn();
88 const OUString strWildcardNumber("%NUMBER%");
90 // write labels to columns
91 for (size_t i = 0; i < aRangeList.size(); i++)
93 if (mGroupedBy == BY_COLUMN)
94 aTemplate.setTemplate(SC_STRLOAD(RID_STATISTICS_DLGS, STR_COLUMN_LABEL_TEMPLATE));
95 else
96 aTemplate.setTemplate(SC_STRLOAD(RID_STATISTICS_DLGS, STR_ROW_LABEL_TEMPLATE));
98 aTemplate.applyNumber(strWildcardNumber, i + 1);
99 output.writeString(aTemplate.getTemplate());
100 output.nextColumn();
103 // write labels to rows
104 output.resetColumn();
105 output.nextRow();
106 for (size_t i = 0; i < aRangeList.size(); i++)
108 if (mGroupedBy == BY_COLUMN)
109 aTemplate.setTemplate(SC_STRLOAD(RID_STATISTICS_DLGS, STR_COLUMN_LABEL_TEMPLATE));
110 else
111 aTemplate.setTemplate(SC_STRLOAD(RID_STATISTICS_DLGS, STR_ROW_LABEL_TEMPLATE));
113 aTemplate.applyNumber(strWildcardNumber, i + 1);
114 output.writeString(aTemplate.getTemplate());
115 output.nextRow();
118 // write correlation formulas
119 output.reset();
120 output.push(1, 1);
122 lclWriteCorrelationFormulas(output, aTemplate, aRangeList, getTemplate());
124 return ScRange(output.mMinimumAddress, output.mMaximumAddress);
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */