dev/null |binary sc/qa/unit/data/contentCSV/cachedValue.csv | 2 sc/qa/unit/data/contentCSV/matrix2.csv | 12 +-- sc/qa/unit/data/ods/cachedValue.ods |binary sc/qa/unit/data/ods/matrix.ods |binary sc/qa/unit/helper/csv_handler.hxx | 4 - sc/qa/unit/subsequent_filters-test.cxx | 95 ++++++++++++++++++----------- sc/source/core/data/cell.cxx | 4 - sc/source/core/tool/formularesult.cxx | 7 ++ sc/source/filter/xml/xmlcelli.cxx | 36 ++++++---- sc/source/filter/xml/xmlcelli.hxx | 6 + sc/source/ui/docshell/docsh.cxx | 4 - 12 files changed, 108 insertions(+), 62 deletions(-)
New commits: commit 71a8f79f4bdf567b6fce23091ca1663455cadba9 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri Jan 25 13:15:09 2013 +0100 improve the tests for cached value import The test now also tests for Err:* import and checks that these have been imported as error values and not only as text values. Future clean-up: Merge the cached matrix test file into the cached value one. Change-Id: I9c0a06f058ff6620bd7ca169b3bee07a5430997e diff --git a/sc/qa/unit/data/contentCSV/matrix2.csv b/sc/qa/unit/data/contentCSV/matrix2.csv index 2effd61..8450f0d 100644 --- a/sc/qa/unit/data/contentCSV/matrix2.csv +++ b/sc/qa/unit/data/contentCSV/matrix2.csv @@ -1,6 +1,6 @@ -Matrices with errors and other misc potential problems:,,,, -Err:502,Err:502,Err:502,,error result -#N/A,#N/A,#N/A,,n/a -TRUE,TRUE,TRUE,,Display TRUE instead of 1 -FALSE,FALSE,FALSE,,Display FALSE instead of 0 -42,,42,,Display blank cell instead of 0 +Matrices with errors and other misc potential problems: +Err:502,Err:502,Err:502, +#N/A,#N/A,#N/A, +TRUE,TRUE,TRUE, +FALSE,FALSE,FALSE, +42,,42,, diff --git a/sc/qa/unit/data/ods/cachedValue.ods b/sc/qa/unit/data/ods/cachedValue.ods index a802e22..8fe411a 100644 Binary files a/sc/qa/unit/data/ods/cachedValue.ods and b/sc/qa/unit/data/ods/cachedValue.ods differ diff --git a/sc/qa/unit/data/ods/matrix.ods b/sc/qa/unit/data/ods/matrix.ods index d3713cf..4d2f836 100644 Binary files a/sc/qa/unit/data/ods/matrix.ods and b/sc/qa/unit/data/ods/matrix.ods differ diff --git a/sc/qa/unit/data/ods/volatile.ods b/sc/qa/unit/data/ods/volatile.ods deleted file mode 100644 index 6278de7..0000000 Binary files a/sc/qa/unit/data/ods/volatile.ods and /dev/null differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index a8c37cb..6182bf3 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -133,7 +133,6 @@ public: void testHardRecalcODS(); void testFunctionsODS(); void testCachedFormulaResultsODS(); - void testVolatileFunctionsODS(); void testCachedMatrixFormulaResultsODS(); void testDatabaseRangesODS(); void testDatabaseRangesXLS(); @@ -188,7 +187,6 @@ public: CPPUNIT_TEST(testHardRecalcODS); CPPUNIT_TEST(testFunctionsODS); CPPUNIT_TEST(testCachedFormulaResultsODS); - CPPUNIT_TEST(testVolatileFunctionsODS); CPPUNIT_TEST(testCachedMatrixFormulaResultsODS); CPPUNIT_TEST(testDatabaseRangesODS); CPPUNIT_TEST(testDatabaseRangesXLS); @@ -460,29 +458,40 @@ void ScFiltersTest::testCachedFormulaResultsODS() createCSVPath("cachedValue.", aCSVFileName); testFile(aCSVFileName, pDoc, 0); - xDocSh->DoClose(); - } -} + //we want to me sure that volatile functions are always recalculated + //regardless of cached results. if you update the ods file, you must + //update the values here. + //if NOW() is recacluated, then it should never equal sTodayCache + OUString sTodayCache("01/25/13 01:06 PM"); + OUString sTodayRecalc(pDoc->GetString(0,0,1)); -void ScFiltersTest::testVolatileFunctionsODS() -{ - ScDocShellRef xDocSh = loadDoc("volatile.", ODS); + CPPUNIT_ASSERT(sTodayCache != sTodayRecalc); - CPPUNIT_ASSERT_MESSAGE("Failed to load volatile.ods", xDocSh.Is()); - ScDocument* pDoc = xDocSh->GetDocument(); - - //we want to me sure that volatile functions are always recalculated - //regardless of cached results. if you update the ods file, you must - //update the values here. - //if NOW() is recacluated, then it should never equal sTodayCache - OUString sTodayCache("07/11/12 12:28 AM"); - OUString sTodayRecalc(pDoc->GetString(0,1,0)); - CPPUNIT_ASSERT(sTodayCache != sTodayRecalc); + OUString sTodayRecalcRef(pDoc->GetString(1,0,1)); + CPPUNIT_ASSERT_EQUAL(sTodayRecalc, sTodayRecalcRef); - OUString sTodayRecalcRef(pDoc->GetString(2,1,0)); - CPPUNIT_ASSERT(sTodayCache != sTodayRecalcRef); + // make sure that error values are not being treated as string values + for(SCCOL nCol = 0; nCol < 4; ++nCol) + { + for(SCROW nRow = 0; nRow < 2; ++nRow) + { + OUStringBuffer aIsErrorFormula("=ISERROR("); + aIsErrorFormula.append((char)('A'+nCol)).append(OUString::number(nRow)); + aIsErrorFormula.append(")"); + OUString aFormula = aIsErrorFormula.makeStringAndClear(); + pDoc->SetString(nCol, nRow + 2, 2, aFormula); + CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8).getStr(), pDoc->GetString(nCol, nRow +2, 2), OUString("TRUE")); + + OUStringBuffer aIsTextFormula("=ISTEXT("); + aIsTextFormula.append((char)('A'+nCol)).append(OUString::number(nRow)); + aIsTextFormula.append(")"); + pDoc->SetString(nCol, nRow + 4, 2, aIsTextFormula.makeStringAndClear()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("", pDoc->GetString(nCol, nRow +4, 2), OUString("FALSE")); + } + } - xDocSh->DoClose(); + xDocSh->DoClose(); + } } void ScFiltersTest::testCachedMatrixFormulaResultsODS() commit 3a1f90a6c7fa0c0604acac6d76f9d4ef3ac20311 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Thu Jan 24 23:22:14 2013 +0100 improve handling of error cells in cahced value import We are finally able to handle error cells of the type Err:* and the patch drastically reduces the number of string comparisons needed during cached value import. Change-Id: I4c0a2ed2561862615fe745d1a556e4004fd28d8f diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index f3265ca..0eeeecb 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -122,7 +122,9 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, bHasTextImport(false), bIsFirstTextImport(false), bSolarMutexLocked(false), - bFormulaTextResult(false) + bFormulaTextResult(false), + mbPossibleErrorCell(false), + mbCheckWithCompilerForError(false) { rtl::math::setNan(&fValue); // NaN by default @@ -729,7 +731,7 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const { if( bFormulaTextResult && pOUTextValue ) { - if (!GetScImport().IsFormulaErrorConstant(*pOUTextValue)) + if( !IsPossibleErrorString() ) { pFCell->SetHybridString( *pOUTextValue ); pFCell->ResetDirty(); @@ -772,7 +774,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos, if(!aCellString.isEmpty()) { - if (bDoIncrement && !GetScImport().IsFormulaErrorConstant(aCellString)) + if (bDoIncrement && !IsPossibleErrorString()) { pFCell->SetHybridString( aCellString ); pFCell->ResetDirty(); @@ -1119,7 +1121,7 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) ScMatrixRef pMat(new ScMatrix(nMatrixCols, nMatrixRows)); if (bFormulaTextResult && pOUTextValue) { - if (!GetScImport().IsFormulaErrorConstant(*pOUTextValue)) + if (!IsPossibleErrorString()) { pFCell->SetResultMatrix( nMatrixCols, nMatrixRows, pMat, new formula::FormulaStringToken(*pOUTextValue)); @@ -1159,14 +1161,20 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) // - is blank // - has a constant error value beginning with "#" (such as "#VALUE!" or "#N/A") // - has an "Err:[###]" (where "[###]" is an error number) -bool ScXMLTableRowCellContext::HasSpecialCaseFormulaText() const +void ScXMLTableRowCellContext::HasSpecialCaseFormulaText() { - if( pOUTextContent && - ( pOUTextContent->isEmpty() || (pOUTextContent->indexOf("#") > -1) || - (pOUTextContent->indexOf("Err:") > -1) ) - ) - return true; - return false; + if( pOUTextContent ) + { + if ( pOUTextContent->isEmpty() || (pOUTextContent->indexOf("Err:") > -1) ) + mbPossibleErrorCell = true; + else if (pOUTextContent->indexOf("#") > -1) + mbCheckWithCompilerForError = true; + } +} + +bool ScXMLTableRowCellContext::IsPossibleErrorString() const +{ + return mbPossibleErrorCell || ( mbCheckWithCompilerForError && GetScImport().IsFormulaErrorConstant(*pOUTextValue) ); } @@ -1185,8 +1193,8 @@ void ScXMLTableRowCellContext::EndElement() aTextImport->ResetCursor(); } } - - if( bFormulaTextResult && HasSpecialCaseFormulaText() ) + HasSpecialCaseFormulaText(); + if( bFormulaTextResult && (mbPossibleErrorCell || mbCheckWithCompilerForError) ) { pOUTextValue.reset(*pOUTextContent); nCellType = util::NumberFormat::TEXT; diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx index 32f0698..2bf8b8c 100644 --- a/sc/source/filter/xml/xmlcelli.hxx +++ b/sc/source/filter/xml/xmlcelli.hxx @@ -65,6 +65,8 @@ class ScXMLTableRowCellContext : public SvXMLImportContext bool bIsFirstTextImport; bool bSolarMutexLocked; bool bFormulaTextResult; + bool mbPossibleErrorCell; + bool mbCheckWithCompilerForError; const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } @@ -92,7 +94,9 @@ class ScXMLTableRowCellContext : public SvXMLImportContext void PutFormulaCell ( const ScAddress& rScCurrentPos ); void AddFormulaCell ( const ScAddress& rScCellPos ); - bool HasSpecialCaseFormulaText() const; + void HasSpecialCaseFormulaText(); + + bool IsPossibleErrorString() const; public: commit 255bec2034fe80a53354b956e46591097880220b Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Thu Jan 24 20:23:55 2013 +0100 improve tests for cached value import Change-Id: I8e5f8cb351792b53c89658074e41dff3a3c4d9db diff --git a/sc/qa/unit/data/contentCSV/cachedValue.csv b/sc/qa/unit/data/contentCSV/cachedValue.csv new file mode 100644 index 0000000..183391b --- /dev/null +++ b/sc/qa/unit/data/contentCSV/cachedValue.csv @@ -0,0 +1,2 @@ +1.00,200.00%,$3.00,1/3/00,00:00,6.00E+000,7 1/5,TRUE,9,1000%,01-10 +1,200.00%,$3.00,01/03/00,120:00:00,6.00E+000,7 1/5,TRUE,9,1000.00%,01/10/00 diff --git a/sc/qa/unit/data/ods/cachedValue.ods b/sc/qa/unit/data/ods/cachedValue.ods new file mode 100644 index 0000000..a802e22 Binary files /dev/null and b/sc/qa/unit/data/ods/cachedValue.ods differ diff --git a/sc/qa/unit/helper/csv_handler.hxx b/sc/qa/unit/helper/csv_handler.hxx index 8493f10..b621baa 100644 --- a/sc/qa/unit/helper/csv_handler.hxx +++ b/sc/qa/unit/helper/csv_handler.hxx @@ -141,7 +141,7 @@ public: std::cout << "result: " << (int)(aCSVString == aString) << std::endl; #endif //DEBUG_CSV_HANDLER - CPPUNIT_ASSERT_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, aCSVString, aString).getStr(), aString == aCSVString); + CPPUNIT_ASSERT_EQUAL_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, aCSVString, aString).getStr(), aString, aCSVString); } else { @@ -169,7 +169,7 @@ public: std::cout << "result: " << (int)(aCSVString == aString) << std::endl; #endif //DEBUG_CSV_HANDLER - CPPUNIT_ASSERT_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, aCSVString, aString).getStr(), aString == aCSVString); + CPPUNIT_ASSERT_EQUAL_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, aCSVString, aString).getStr(), aString, aCSVString); } else { diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index c8dcf40..a8c37cb 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -188,8 +188,8 @@ public: CPPUNIT_TEST(testHardRecalcODS); CPPUNIT_TEST(testFunctionsODS); CPPUNIT_TEST(testCachedFormulaResultsODS); - //CPPUNIT_TEST(testVolatileFunctionsODS); - //CPPUNIT_TEST(testCachedMatrixFormulaResultsODS); + CPPUNIT_TEST(testVolatileFunctionsODS); + CPPUNIT_TEST(testCachedMatrixFormulaResultsODS); CPPUNIT_TEST(testDatabaseRangesODS); CPPUNIT_TEST(testDatabaseRangesXLS); CPPUNIT_TEST(testDatabaseRangesXLSX); @@ -428,26 +428,40 @@ void ScFiltersTest::testFunctionsODS() void ScFiltersTest::testCachedFormulaResultsODS() { - ScDocShellRef xDocSh = loadDoc("functions.", ODS); - CPPUNIT_ASSERT_MESSAGE("Failed to load functions.*", xDocSh.Is()); + { + ScDocShellRef xDocSh = loadDoc("functions.", ODS); + CPPUNIT_ASSERT_MESSAGE("Failed to load functions.*", xDocSh.Is()); - ScDocument* pDoc = xDocSh->GetDocument(); - rtl::OUString aCSVFileName; + ScDocument* pDoc = xDocSh->GetDocument(); + rtl::OUString aCSVFileName; - //test cached formula results of logical functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("logical-functions.")), aCSVFileName); - testFile(aCSVFileName, pDoc, 0); - //test cached formula results of spreadsheet functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("spreadsheet-functions.")), aCSVFileName); - testFile(aCSVFileName, pDoc, 1); - //test cached formula results of mathematical functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mathematical-functions.")), aCSVFileName); - testFile(aCSVFileName, pDoc, 2, PureString); - //test cached formula results of informations functions - createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("information-functions.")), aCSVFileName); - testFile(aCSVFileName, pDoc, 3); + //test cached formula results of logical functions + createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("logical-functions.")), aCSVFileName); + testFile(aCSVFileName, pDoc, 0); + //test cached formula results of spreadsheet functions + createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("spreadsheet-functions.")), aCSVFileName); + testFile(aCSVFileName, pDoc, 1); + //test cached formula results of mathematical functions + createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mathematical-functions.")), aCSVFileName); + testFile(aCSVFileName, pDoc, 2, PureString); + //test cached formula results of informations functions + createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("information-functions.")), aCSVFileName); + testFile(aCSVFileName, pDoc, 3); - xDocSh->DoClose(); + xDocSh->DoClose(); + } + + { + ScDocShellRef xDocSh = loadDoc("cachedValue.", ODS); + CPPUNIT_ASSERT_MESSAGE("Failed to load cachedValue.*", xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + rtl::OUString aCSVFileName; + createCSVPath("cachedValue.", aCSVFileName); + testFile(aCSVFileName, pDoc, 0); + + xDocSh->DoClose(); + } } void ScFiltersTest::testVolatileFunctionsODS() commit de7985809f5e01f274e5d7a946e431ae475ea1e7 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Thu Jan 24 20:24:46 2013 +0100 a few more fixes for cached value import Change-Id: I2b6baedc8232811df1e5525bd2884b54db5a8f70 diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index 8df14f1..0967e81 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -1587,7 +1587,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) } else { - if ( eOld == svHybridCell ) // string result from SetFormulaResultString? + if ( eOld == svHybridCell || eOld == svHybridValueCell ) // string result from SetFormulaResultString? eOld = svString; // ScHybridCellToken has a valid GetString method // #i106045# use approxEqual to compare with stored value @@ -1612,7 +1612,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam ) if ( bChanged && !bContentChanged && pDocument->IsStreamValid(aPos.Tab()) ) { if ( ( eOld == svUnknown && ( eNew == svError || ( eNew == svDouble && aNewResult.GetDouble() == 0.0 ) ) ) || - ( eOld == svHybridCell && eNew == svString && aResult.GetString() == aNewResult.GetString() ) || + ( (eOld == svHybridCell || eOld == svHybridValueCell) && eNew == svString && aResult.GetString() == aNewResult.GetString() ) || ( eOld == svDouble && eNew == svDouble && rtl::math::approxEqual( aResult.GetDouble(), aNewResult.GetDouble() ) ) ) { // no change, see above diff --git a/sc/source/core/tool/formularesult.cxx b/sc/source/core/tool/formularesult.cxx index 9602c44..791dbad 100644 --- a/sc/source/core/tool/formularesult.cxx +++ b/sc/source/core/tool/formularesult.cxx @@ -448,9 +448,16 @@ void ScFormulaResult::SetHybridFormula( const String & rFormula ) void ScFormulaResult::SetHybridValueString( double nVal, const OUString& rStr ) { + if(GetType() == formula::svMatrixCell) + { + SetDouble(nVal); + return; + } + ResetToDefaults(); if (mbToken && mpToken) mpToken->DecRef(); + mpToken = new ScHybridValueCellToken( nVal, rStr ); mpToken->IncRef(); mbToken = true; diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index e93f33d..f3265ca 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -352,7 +352,7 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos(); - if( ((nCellType == util::NumberFormat::TEXT) || pOUFormula) ) + if( ((nCellType == util::NumberFormat::TEXT) || pOUFormula || bFormulaTextResult) ) { if ( pOUFormula ) { diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 84b5364..79e7dd0 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -470,8 +470,10 @@ sal_Bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::un if (bHardRecalc) DoHardRecalc(false); else + { // still need to recalc volatile formula cells. - aDocument.CalcFormulaTree(false, true, false); + aDocument.Broadcast( SC_HINT_DATACHANGED, BCA_BRDCST_ALWAYS, NULL ); + } bool bAdjustHeightOld = aDocument.IsAdjustHeightEnabled(); aDocument.EnableAdjustHeight(false); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits