sc/qa/unit/pivottable_filters_test.cxx | 5 +++-- sc/source/filter/excel/xestream.cxx | 5 ++++- sc/source/filter/oox/formulabuffer.cxx | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-)
New commits: commit e4f76cd9a4814ce6cc4795e5e1a5c74d54cb7513 Author: Justin Luth <justin_l...@sil.org> AuthorDate: Wed Feb 23 10:34:29 2022 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Wed Mar 2 13:05:22 2022 +0100 tdf#122098 xlsx im/export: let formulas guess their number format SQUASHED backport: includes followup commit 5a64b618d84edb65465950d54e3b4afc952a301c This fixes the import side of a LO 4.2 regression from commit 07b66cd3ac1a9f6c7b61a1d7da6e9d266e6de92d and the export side of a LO 4.3 regression from commit 69ecdad805281b2cb6ec2437da18daa19576deae make CppunitTest_sc_pivottable_filters_test \ CPPUNIT_TEST_NAME=testPivotTableBoolFieldFilterXLSX Change-Id: I4c680dbff844cf1eca52de641856daafa032eeb4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130406 Tested-by: Justin Luth <jl...@mail.com> Reviewed-by: Justin Luth <jl...@mail.com> (cherry picked from commit 8f5d8669ca74fed8608e438a8436c173e35d43a6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130386 Tested-by: Jenkins Reviewed-by: Eike Rathke <er...@redhat.com> diff --git a/sc/qa/unit/pivottable_filters_test.cxx b/sc/qa/unit/pivottable_filters_test.cxx index 8ad8fbffee81..80557c5b12aa 100644 --- a/sc/qa/unit/pivottable_filters_test.cxx +++ b/sc/qa/unit/pivottable_filters_test.cxx @@ -2201,6 +2201,7 @@ void ScPivotTableFiltersTest::testPivotTableBoolFieldFilterXLSX() ScDocument& rDoc = xDocSh->GetDocument(); ScDPCollection* pDPs = rDoc.GetDPCollection(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount()); + CPPUNIT_ASSERT_EQUAL(OUString("TRUE"), rDoc.GetString(ScAddress(0, 1, 0))); //A2 // Reload and check filtering of row dimensions xDocSh = saveAndReload(&(*xDocSh), FORMAT_XLSX); @@ -2218,11 +2219,11 @@ void ScPivotTableFiltersTest::testPivotTableBoolFieldFilterXLSX() const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); CPPUNIT_ASSERT_EQUAL(size_t(2), rMembers.size()); - ScDPSaveMember* pMember = pSaveDim->GetExistingMemberByName("0"); + ScDPSaveMember* pMember = pSaveDim->GetExistingMemberByName("FALSE"); CPPUNIT_ASSERT(pMember); CPPUNIT_ASSERT(pMember->HasIsVisible()); CPPUNIT_ASSERT(!pMember->GetIsVisible()); - pMember = pSaveDim->GetExistingMemberByName("1"); + pMember = pSaveDim->GetExistingMemberByName("TRUE"); CPPUNIT_ASSERT(pMember); CPPUNIT_ASSERT(pMember->HasIsVisible()); CPPUNIT_ASSERT(pMember->GetIsVisible()); diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index 17395145bbab..3b49c5d6b9e2 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -670,7 +670,10 @@ void XclXmlUtils::GetFormulaTypeAndValue( ScFormulaCell& rCell, const char*& rsT rsValue = ToOUString(lcl_GetErrorString(aResValue.mnError)); break; case sc::FormulaResultValue::Value: - rsType = "n"; + rsType = rCell.GetFormatType() == SvNumFormatType::LOGICAL + && (aResValue.mfValue == 0.0 || aResValue.mfValue == 1.0) + ? "b" + : "n"; rsValue = OUString::number(aResValue.mfValue); break; case sc::FormulaResultValue::String: diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx index 2aeccb1b37b7..7fcc4f5e259f 100644 --- a/sc/source/filter/oox/formulabuffer.cxx +++ b/sc/source/filter/oox/formulabuffer.cxx @@ -153,6 +153,9 @@ void applySharedFormulas( pCell = new ScFormulaCell(rDoc.getDoc(), aPos, *pArray); rDoc.setFormulaCell(aPos, pCell); + if (rDoc.getDoc().GetNumberFormat(aPos.Col(), aPos.Row(), aPos.Tab()) % SV_COUNTRY_LANGUAGE_OFFSET == 0) + pCell->SetNeedNumberFormat(true); + if (rDesc.maCellValue.isEmpty()) { // No cached cell value. Mark it for re-calculation. @@ -227,6 +230,8 @@ void applyCellFormulas( pCell = new ScFormulaCell(rDoc.getDoc(), aPos, p->mpCell->GetCode()->Clone()); rDoc.setFormulaCell(aPos, pCell); + if (rDoc.getDoc().GetNumberFormat(aPos.Col(), aPos.Row(), aPos.Tab()) % SV_COUNTRY_LANGUAGE_OFFSET == 0) + pCell->SetNeedNumberFormat(true); // Update the cache. p->mnRow = aPos.Row(); @@ -245,6 +250,8 @@ void applyCellFormulas( ScFormulaCell* pCell = new ScFormulaCell(rDoc.getDoc(), aPos, std::move(pCode)); rDoc.setFormulaCell(aPos, pCell); + if (rDoc.getDoc().GetNumberFormat(aPos.Col(), aPos.Row(), aPos.Tab()) % SV_COUNTRY_LANGUAGE_OFFSET == 0) + pCell->SetNeedNumberFormat(true); rCache.store(aPos, pCell); } }