summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2022-02-23 10:34:29 +0200
committerEike Rathke <erack@redhat.com>2022-03-02 13:05:22 +0100
commite4f76cd9a4814ce6cc4795e5e1a5c74d54cb7513 (patch)
tree77d41291f1cb8f88ecd2486189dd550cc74bc805 /sc
parent8f4e7b39092252646dae61488f35a500398c043f (diff)
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 <jluth@mail.com> Reviewed-by: Justin Luth <jluth@mail.com> (cherry picked from commit 8f5d8669ca74fed8608e438a8436c173e35d43a6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130386 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/pivottable_filters_test.cxx5
-rw-r--r--sc/source/filter/excel/xestream.cxx5
-rw-r--r--sc/source/filter/oox/formulabuffer.cxx7
3 files changed, 14 insertions, 3 deletions
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);
}
}