sc/source/ui/optdlg/calcoptionsdlg.cxx | 56 +++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 16 deletions(-)
New commits: commit 634a69019189389cc8a7154c846454807fce96a3 Author: Tor Lillqvist <[email protected]> Date: Mon Nov 24 13:14:54 2014 +0200 Reduce the amount of data by an order of magnitude Change-Id: I4a1deb2c1a0cfe67faef6a0d2e3d355b475eb9f0 diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx index c800726..0b0d160 100644 --- a/sc/source/ui/optdlg/calcoptionsdlg.cxx +++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx @@ -1038,7 +1038,7 @@ struct Op : Area const OUString& rOp, double nRangeLo, double nRangeHi, double nEpsilon) : - Area(rTitle, 1000), + Area(rTitle, 200), msOp(rOp), mnRangeLo(nRangeLo), mnRangeHi(nRangeHi), @@ -1355,31 +1355,31 @@ IMPL_LINK( ScCalcOptionsDialog, TestClickHdl, PushButton*, ) return (nArg == 0); })); - pTestDocument->addTest(Reduction("Sum", "SUM", 500, 0, -1000, 1000, 3e-10, + pTestDocument->addTest(Reduction("Sum", "SUM", 100, 0, -1000, 1000, 3e-10, [] (double nAccum, double nArg) { return (nAccum + nArg); })); - pTestDocument->addTest(Reduction("Average", "AVERAGE", 500, 0, -1000, 1000, 3e-10, + pTestDocument->addTest(Reduction("Average", "AVERAGE", 100, 0, -1000, 1000, 3e-10, [] (double nAccum, double nArg) { - return (nAccum + nArg / static_cast<double>(500)); + return (nAccum + nArg/100.); })); - pTestDocument->addTest(Reduction("Product", "PRODUCT", 500, 1, 0.1, 2.5, 3e-10, + pTestDocument->addTest(Reduction("Product", "PRODUCT", 100, 1, 0.1, 2.5, 3e-10, [] (double nAccum, double nArg) { return (nAccum * nArg); })); - pTestDocument->addTest(Reduction("Min", "MIN", 500, DBL_MAX, -1000, 1000, 0, + pTestDocument->addTest(Reduction("Min", "MIN", 100, DBL_MAX, -1000, 1000, 0, [] (double nAccum, double nArg) { return std::min(nAccum, nArg); })); - pTestDocument->addTest(Reduction("Max", "MAX", 500, -DBL_MAX, -1000, 1000, 0, + pTestDocument->addTest(Reduction("Max", "MAX", 100, -DBL_MAX, -1000, 1000, 0, [] (double nAccum, double nArg) { return std::max(nAccum, nArg); commit c6f1f948178ab29ea190117376cb9365d8f4fd7b Author: Tor Lillqvist <[email protected]> Date: Mon Nov 24 13:08:01 2014 +0200 Add AVERAGE test Change-Id: I144858631f229685284622eb9975a168e61ff6c5 diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx index ebaf2ed..c800726 100644 --- a/sc/source/ui/optdlg/calcoptionsdlg.cxx +++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx @@ -1361,6 +1361,12 @@ IMPL_LINK( ScCalcOptionsDialog, TestClickHdl, PushButton*, ) return (nAccum + nArg); })); + pTestDocument->addTest(Reduction("Average", "AVERAGE", 500, 0, -1000, 1000, 3e-10, + [] (double nAccum, double nArg) + { + return (nAccum + nArg / static_cast<double>(500)); + })); + pTestDocument->addTest(Reduction("Product", "PRODUCT", 500, 1, 0.1, 2.5, 3e-10, [] (double nAccum, double nArg) { commit 62a06cd0a9ab053d6560f7395a4b0f339c2fbe58 Author: Tor Lillqvist <[email protected]> Date: Mon Nov 24 13:03:52 2014 +0200 Add MIN and MAX tests Change-Id: Ia8d5fdeb1e03009035136edeab991442b7d91c4b diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx index 1d7c6f1..ebaf2ed 100644 --- a/sc/source/ui/optdlg/calcoptionsdlg.cxx +++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx @@ -1367,6 +1367,18 @@ IMPL_LINK( ScCalcOptionsDialog, TestClickHdl, PushButton*, ) return (nAccum * nArg); })); + pTestDocument->addTest(Reduction("Min", "MIN", 500, DBL_MAX, -1000, 1000, 0, + [] (double nAccum, double nArg) + { + return std::min(nAccum, nArg); + })); + + pTestDocument->addTest(Reduction("Max", "MAX", 500, -DBL_MAX, -1000, 1000, 0, + [] (double nAccum, double nArg) + { + return std::max(nAccum, nArg); + })); + return 0; } commit 9d842b485f6c1a0d50d3d9d80ef8a61060645a62 Author: Tor Lillqvist <[email protected]> Date: Mon Nov 24 12:59:30 2014 +0200 Fix fencepost errors Change-Id: I4d22d535368569631be9c016f74b7c19b9019955 diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx index 3a0af0e..1d7c6f1 100644 --- a/sc/source/ui/optdlg/calcoptionsdlg.cxx +++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx @@ -1217,7 +1217,7 @@ struct Reduction : Op virtual void addHeader(ScDocument *pDoc, int nTab) const SAL_OVERRIDE { pDoc->SetString(ScAddress(0,0,nTab), "x"); - pDoc->SetString(ScAddress(1,0,nTab), msOp + "(" + OUString::number(mnNum) + ")"); + pDoc->SetString(ScAddress(1,0,nTab), msOp); pDoc->SetString(ScAddress(2,0,nTab), "expected"); } @@ -1231,33 +1231,39 @@ struct Reduction : Op pDoc->SetValue(ScAddress(0,1+nRow,nTab), nArg); - if (nRow >= mnNum) + if (nRow >= mnNum-1) { - pDoc->SetString(ScAddress(1,1+nRow,nTab), + pDoc->SetString(ScAddress(1,1+nRow-mnNum+1,nTab), OUString("=") + msOp + "(" + - ScRange(ScAddress(0,1+nRow-mnNum,nTab), + ScRange(ScAddress(0,1+nRow-mnNum+1,nTab), ScAddress(0,1+nRow,nTab)).Format(SCA_VALID|SCA_TAB_3D|SCA_VALID_COL|SCA_VALID_ROW) + ")"); double nAccum(mnAccumInitial); for (int i = 0; i < mnNum; i++) - nAccum = mpFun(nAccum, pDoc->GetValue(ScAddress(0,1+nRow-mnNum+i,nTab))); + nAccum = mpFun(nAccum, pDoc->GetValue(ScAddress(0,1+nRow-mnNum+i+1,nTab))); - pDoc->SetValue(ScAddress(2,1+nRow,nTab), nAccum); + pDoc->SetValue(ScAddress(2,1+nRow-mnNum+1,nTab), nAccum); - pDoc->SetString(ScAddress(3,1+nRow,nTab), - OUString("=IF(ABS(") + ScAddress(1,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + - "-" + ScAddress(2,1+nRow,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + - ")<=" + OUString::number(mnEpsilon) + - ",0,1)"); + if (mnEpsilon != 0) + pDoc->SetString(ScAddress(3,1+nRow-mnNum+1,nTab), + OUString("=IF(ABS(") + ScAddress(1,1+nRow-mnNum+1,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + + "-" + ScAddress(2,1+nRow-mnNum+1,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + + ")<=" + OUString::number(mnEpsilon) + + ",0,1)"); + else + pDoc->SetString(ScAddress(3,1+nRow-mnNum+1,nTab), + OUString("=IF(") + ScAddress(1,1+nRow-mnNum+1,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + + "=" + ScAddress(2,1+nRow-mnNum+1,nTab).Format(SCA_VALID_COL|SCA_VALID_ROW) + + ",0,1)"); } } virtual OUString getSummaryFormula(ScDocument *pDoc, int nTab) const SAL_OVERRIDE { return OUString("=SUM(") + - ScRange(ScAddress(3,1+mnNum,nTab), - ScAddress(3,1+mnRows-1,nTab)).Format(SCA_VALID|SCA_TAB_3D|SCA_VALID_COL|SCA_VALID_ROW|SCA_VALID_TAB, pDoc) + + ScRange(ScAddress(3,1+0,nTab), + ScAddress(3,1+mnRows-mnNum-1,nTab)).Format(SCA_VALID|SCA_TAB_3D|SCA_VALID_COL|SCA_VALID_ROW|SCA_VALID_TAB, pDoc) + ")"; } }; commit c7d2794d5689e10283d0abbe0b6d422a85795410 Author: Tor Lillqvist <[email protected]> Date: Mon Nov 24 12:21:52 2014 +0200 The initial value for PRODUCT should obviously be one, not zero Change-Id: Id054d66e716fb5b176b687afc5d4121f3fa13765 diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx index ab52adb..3a0af0e 100644 --- a/sc/source/ui/optdlg/calcoptionsdlg.cxx +++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx @@ -1355,7 +1355,7 @@ IMPL_LINK( ScCalcOptionsDialog, TestClickHdl, PushButton*, ) return (nAccum + nArg); })); - pTestDocument->addTest(Reduction("Product", "PRODUCT", 500, 0, 0.1, 2.5, 3e-10, + pTestDocument->addTest(Reduction("Product", "PRODUCT", 500, 1, 0.1, 2.5, 3e-10, [] (double nAccum, double nArg) { return (nAccum * nArg); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
