[Libreoffice-commits] core.git: sc/qa

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Wed May 12 18:29:16 UTC 2021


 sc/qa/unit/ucalc.cxx         |  125 +++++++++++++++++++++++++++++++++++++++++--
 sc/qa/unit/ucalc_formula.cxx |   58 ++++++++++++++++++-
 sc/qa/unit/ucalc_sort.cxx    |   14 +++-
 3 files changed, 183 insertions(+), 14 deletions(-)

New commits:
commit 145b2d8ee131dca592a41f7b26341a542a23845b
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Wed May 12 16:56:18 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Wed May 12 20:28:37 2021 +0200

    sc_ucalc: restore formula options after using them
    
    Otherwise, it might affect other unittests
    
    Change-Id: I0750979742e6193f627a1eaf9b1e35f97976278b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115490
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 46220aa76f55..72e25f2f5b91 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4644,10 +4644,10 @@ void Test::executeCopyPasteSpecial(bool bApplyFilter, bool bIncludedFiltered, bo
                                    InsertDeleteFlags aFlags
                                    = InsertDeleteFlags::CONTENTS | InsertDeleteFlags::ATTRIB)
 {
-    // Reset settings needed for SUMIF() if run with other tests
-    ScFormulaOptions aOptions;
-    aOptions.SetFormulaSepArg(";");
-    getDocShell().SetFormulaOptions(aOptions);
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
 
     const SCTAB srcSheet = 0;
     m_pDoc->InsertTab(srcSheet, "SrcSheet");
@@ -5058,6 +5058,9 @@ void Test::executeCopyPasteSpecial(bool bApplyFilter, bool bIncludedFiltered, bo
     }
     if (bCalcAll)
         m_pDoc->CalcAll();
+
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
 }
 
 void Test::testCopyPasteSpecial()
@@ -5359,6 +5362,11 @@ void Test::checkCopyPasteSpecial(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
          |  D  |    E     | F  |  G  |     H      |        I            |
 
@@ -5631,6 +5639,9 @@ void Test::checkCopyPasteSpecial(bool bSkipEmpty)
 
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
+
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
 }
 
 void Test::checkCopyPasteSpecialFiltered(bool bSkipEmpty)
@@ -5638,6 +5649,11 @@ void Test::checkCopyPasteSpecialFiltered(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
          |  D  |    E     | F  |  G  |     H      |        I            |
 
@@ -5900,6 +5916,9 @@ void Test::checkCopyPasteSpecialFiltered(bool bSkipEmpty)
     CPPUNIT_ASSERT_EQUAL(m_pDoc->GetNote(ScAddress(5, 3, srcSheet))->GetText(),
                          m_pDoc->GetNote(ScAddress(8, 3, destSheet))->GetText());
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
 }
@@ -5909,6 +5928,11 @@ void Test::checkCopyPasteSpecialTranspose(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
              |         D          |    E     |    F     |       G       |
 
@@ -6294,6 +6318,9 @@ void Test::checkCopyPasteSpecialTranspose(bool bSkipEmpty)
                                  m_pDoc->GetNote(ScAddress(5, 3, srcSheet))->GetText(),
                                  m_pDoc->GetNote(ScAddress(6, 6, destSheet))->GetText());
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
 }
@@ -6303,6 +6330,11 @@ void Test::checkCopyPasteSpecialFilteredTranspose(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
                                   ┌--- filtered src row 2          ┌--- repeated row
                                   v                                v
@@ -6701,6 +6733,9 @@ void Test::checkCopyPasteSpecialFilteredTranspose(bool bSkipEmpty)
                                  m_pDoc->GetNote(ScAddress(5, 3, srcSheet))->GetText(),
                                  m_pDoc->GetNote(ScAddress(5, 6, destSheet))->GetText());
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
 }
@@ -6710,6 +6745,11 @@ void Test::checkCopyPasteSpecialMultiRangeCol(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
                           ┌--- not selected src col C
                           v
@@ -6976,6 +7016,9 @@ void Test::checkCopyPasteSpecialMultiRangeCol(bool bSkipEmpty)
     CPPUNIT_ASSERT_EQUAL(m_pDoc->GetNote(ScAddress(5, 3, srcSheet))->GetText(),
                          m_pDoc->GetNote(ScAddress(7, 4, destSheet))->GetText());
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
 }
@@ -6985,6 +7028,11 @@ void Test::checkCopyPasteSpecialMultiRangeColFiltered(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
                           ┌--- not selected src col C
                           v
@@ -7206,6 +7254,9 @@ void Test::checkCopyPasteSpecialMultiRangeColFiltered(bool bSkipEmpty)
     CPPUNIT_ASSERT_EQUAL(m_pDoc->GetNote(ScAddress(5, 3, srcSheet))->GetText(),
                          m_pDoc->GetNote(ScAddress(7, 3, destSheet))->GetText());
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
 }
@@ -7215,6 +7266,11 @@ void Test::checkCopyPasteSpecialMultiRangeColTranspose(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
              |         D          |    E     |    F     |       G       |
 
@@ -7484,6 +7540,9 @@ void Test::checkCopyPasteSpecialMultiRangeColTranspose(bool bSkipEmpty)
     CPPUNIT_ASSERT_EQUAL(m_pDoc->GetNote(ScAddress(5, 3, srcSheet))->GetText(),
                          m_pDoc->GetNote(ScAddress(6, 5, destSheet))->GetText());
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
 }
@@ -7493,6 +7552,11 @@ void Test::checkCopyPasteSpecialMultiRangeColFilteredTranspose(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
                                   ┌--- filtered src row 2
                                   v
@@ -7734,6 +7798,9 @@ void Test::checkCopyPasteSpecialMultiRangeColFilteredTranspose(bool bSkipEmpty)
     CPPUNIT_ASSERT_EQUAL(m_pDoc->GetNote(ScAddress(5, 3, srcSheet))->GetText(),
                          m_pDoc->GetNote(ScAddress(5, 5, destSheet))->GetText());
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
 }
@@ -7743,6 +7810,11 @@ void Test::checkCopyPasteSpecialMultiRangeRow(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
          |  D  |    E     | F    |  G   |     H      |        I            |
 
@@ -8057,6 +8129,9 @@ void Test::checkCopyPasteSpecialMultiRangeRow(bool bSkipEmpty)
     CPPUNIT_ASSERT_EQUAL(m_pDoc->GetNote(ScAddress(2, 4, srcSheet))->GetText(),
                          m_pDoc->GetNote(ScAddress(5, 4, destSheet))->GetText());
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
 }
@@ -8066,6 +8141,11 @@ void Test::checkCopyPasteSpecialMultiRangeRowFiltered(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
          |  D  |    E     | F  |  G  |     H      |        I            |
 
@@ -8334,6 +8414,9 @@ void Test::checkCopyPasteSpecialMultiRangeRowFiltered(bool bSkipEmpty)
     CPPUNIT_ASSERT_EQUAL(m_pDoc->GetNote(ScAddress(2, 4, srcSheet))->GetText(),
                          m_pDoc->GetNote(ScAddress(5, 3, destSheet))->GetText());
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
 }
@@ -8343,6 +8426,11 @@ void Test::checkCopyPasteSpecialMultiRangeRowTranspose(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
              |         D          |    E     |    F     | G  |  H  |
 
@@ -8723,6 +8811,9 @@ void Test::checkCopyPasteSpecialMultiRangeRowTranspose(bool bSkipEmpty)
     CPPUNIT_ASSERT_EQUAL(m_pDoc->GetNote(ScAddress(2, 4, srcSheet))->GetText(),
                          m_pDoc->GetNote(ScAddress(6, 3, destSheet))->GetText());
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
 }
@@ -8732,6 +8823,11 @@ void Test::checkCopyPasteSpecialMultiRangeRowFilteredTranspose(bool bSkipEmpty)
     const SCTAB srcSheet = 0;
     const SCTAB destSheet = 1;
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     /*
              |         D          |    E     | F  |  G  |
 
@@ -9069,6 +9165,9 @@ void Test::checkCopyPasteSpecialMultiRangeRowFilteredTranspose(bool bSkipEmpty)
     CPPUNIT_ASSERT_EQUAL(m_pDoc->GetNote(ScAddress(2, 4, srcSheet))->GetText(),
                          m_pDoc->GetNote(ScAddress(5, 3, destSheet))->GetText());
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(destSheet);
     m_pDoc->DeleteTab(srcSheet);
 }
@@ -12632,6 +12731,12 @@ void Test::testProtectedSheetEditByRow()
     ScDocFunc& rDocFunc = getDocShell().GetDocFunc();
     m_pDoc->InsertTab(0, "Protected");
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    aNewOptions.SetFormulaSepArrayCol(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     {
         // Remove protected flags from rows 2-5.
         ScPatternAttr aAttr(m_pDoc->GetPool());
@@ -12699,6 +12804,9 @@ void Test::testProtectedSheetEditByRow()
         CPPUNIT_ASSERT_MESSAGE("row insertion at row 3 should fail.", !bInserted);
     }
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(1);
     m_pDoc->DeleteTab(0);
 }
@@ -12708,6 +12816,12 @@ void Test::testProtectedSheetEditByColumn()
     ScDocFunc& rDocFunc = getDocShell().GetDocFunc();
     m_pDoc->InsertTab(0, "Protected");
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    aNewOptions.SetFormulaSepArrayCol(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     {
         // Remove protected flags from columns B to E.
         ScPatternAttr aAttr(m_pDoc->GetPool());
@@ -12775,6 +12889,9 @@ void Test::testProtectedSheetEditByColumn()
         CPPUNIT_ASSERT_MESSAGE("column insertion at column C should fail.", !bInserted);
     }
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(1);
     m_pDoc->DeleteTab(0);
 }
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 93cd3b5f24d9..65876d57a520 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -32,6 +32,7 @@
 #include <docoptio.hxx>
 #include <formulaopt.hxx>
 #include <externalrefmgr.hxx>
+#include <scmod.hxx>
 #include <svl/itemset.hxx>
 
 #include <formula/vectortoken.hxx>
@@ -1016,11 +1017,12 @@ void Test::testFormulaCompilerJumpReordering()
     };
 
     // Set separators first.
-    ScFormulaOptions aOptions;
-    aOptions.SetFormulaSepArg(";");
-    aOptions.SetFormulaSepArrayCol(";");
-    aOptions.SetFormulaSepArrayRow("|");
-    getDocShell().SetFormulaOptions(aOptions);
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    aNewOptions.SetFormulaSepArrayCol(";");
+    aNewOptions.SetFormulaSepArrayRow("|");
+    getDocShell().SetFormulaOptions(aNewOptions);
 
     {
         // Compile formula string first.
@@ -1079,6 +1081,9 @@ void Test::testFormulaCompilerJumpReordering()
                 CPPUNIT_ASSERT_EQUAL(static_cast<int>(aCheckRPN2[i].meType), static_cast<int>(p->GetType()));
         }
     }
+
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
 }
 
 void Test::testFormulaCompilerImplicitIntersection2Param()
@@ -5008,6 +5013,11 @@ void Test::testFuncCOUNTIF()
 {
     sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     // COUNTIF (test case adopted from OOo i#36381)
 
     CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
@@ -5121,6 +5131,9 @@ void Test::testFuncCOUNTIF()
     CPPUNIT_ASSERT_EQUAL_MESSAGE("One cell with 0.0",  1.0, m_pDoc->GetValue(ScAddress(0,0,0)));
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Two cells with 1.0", 2.0, m_pDoc->GetValue(ScAddress(0,1,0)));
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(0);
 }
 
@@ -5128,6 +5141,12 @@ void Test::testFuncIF()
 {
     sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    aNewOptions.SetFormulaSepArrayCol(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     m_pDoc->InsertTab(0, "Formula");
 
     m_pDoc->SetString(ScAddress(0,0,0), "=IF(B1=2;\"two\";\"not two\")");
@@ -5170,6 +5189,9 @@ void Test::testFuncIF()
     CPPUNIT_ASSERT_EQUAL(34.0, m_pDoc->GetValue(ScAddress(0,10,0)));
     CPPUNIT_ASSERT_EQUAL(56.0, m_pDoc->GetValue(ScAddress(1,10,0)));
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(0);
 }
 
@@ -6122,6 +6144,11 @@ void Test::testFuncINDIRECT()
 //
 void Test::testFuncINDIRECT2()
 {
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
                             m_pDoc->InsertTab (0, "foo"));
     CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
@@ -6181,6 +6208,9 @@ void Test::testFuncINDIRECT2()
     CPPUNIT_ASSERT_MESSAGE("This should be a formula cell.", pFC);
     CPPUNIT_ASSERT_MESSAGE("This formula cell should be an error.", pFC->GetErrCode() != FormulaError::NONE);
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(2);
     m_pDoc->DeleteTab(1);
     m_pDoc->DeleteTab(0);
@@ -7197,6 +7227,11 @@ void Test::testFuncTableRef()
 {
     sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     m_pDoc->InsertTab(0, "Sheet1");
     ScMarkData aMark(m_pDoc->GetSheetLimits());
     aMark.SelectOneTable(0);
@@ -7536,6 +7571,9 @@ void Test::testFuncTableRef()
         CPPUNIT_ASSERT_EQUAL( OUString(aPrefix + "448"), OUString(aPrefix + m_pDoc->GetString(aPos)));
     }
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(0);
 }
 
@@ -8409,6 +8447,13 @@ void Test::testFormulaErrorPropagation()
 {
     sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
 
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    aNewOptions.SetFormulaSepArrayCol(";");
+    aNewOptions.SetFormulaSepArrayRow("|");
+    getDocShell().SetFormulaOptions(aNewOptions);
+
     m_pDoc->InsertTab(0, "Sheet1");
 
     ScMarkData aMark(m_pDoc->GetSheetLimits());
@@ -8477,6 +8522,9 @@ void Test::testFormulaErrorPropagation()
     CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos.Format(ScRefFlags::VALID).toUtf8().getStr(), aTRUE, m_pDoc->GetString(aPos));
     CPPUNIT_ASSERT_EQUAL_MESSAGE( aPos2.Format(ScRefFlags::VALID).toUtf8().getStr(), aFALSE, m_pDoc->GetString(aPos2));
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(0);
 }
 
diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index 8ff3cf58e60d..58b6e5016674 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -129,11 +129,12 @@ void Test::testSortHorizontal()
 {
     SortRefUpdateSetter aUpdateSet;
 
-    ScFormulaOptions aOptions;
-    aOptions.SetFormulaSepArg(";");
-    aOptions.SetFormulaSepArrayCol(";");
-    aOptions.SetFormulaSepArrayRow("|");
-    getDocShell().SetFormulaOptions(aOptions);
+    ScFormulaOptions aOldOptions, aNewOptions;
+    aOldOptions = SC_MOD()->GetFormulaOptions();
+    aNewOptions.SetFormulaSepArg(";");
+    aNewOptions.SetFormulaSepArrayCol(";");
+    aNewOptions.SetFormulaSepArrayRow("|");
+    getDocShell().SetFormulaOptions(aNewOptions);
 
     sc::AutoCalcSwitch aACSwitch(*m_pDoc, true);
     m_pDoc->InsertTab(0, "Sort");
@@ -195,6 +196,9 @@ void Test::testSortHorizontal()
     ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "CONCATENATE(C3;\"-\";D3)", "Wrong formula!");
     ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,3,0), "CONCATENATE(C4;\"-\";D4)", "Wrong formula!");
 
+    // restore formula options back to default
+    getDocShell().SetFormulaOptions(aOldOptions);
+
     m_pDoc->DeleteTab(0);
 }
 


More information about the Libreoffice-commits mailing list