sc/qa/unit/pivottable_filters_test.cxx |    5 +++--
 sc/source/filter/excel/xestream.cxx    |   12 ++++++++++--
 sc/source/filter/oox/formulabuffer.cxx |    7 +++++++
 3 files changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 8f5d8669ca74fed8608e438a8436c173e35d43a6
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Wed Feb 23 10:34:29 2022 +0200
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Wed Feb 23 16:48:56 2022 +0100

    tdf#122098 xlsx im/export: let formulas guess their number format
    
    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>

diff --git a/sc/qa/unit/pivottable_filters_test.cxx 
b/sc/qa/unit/pivottable_filters_test.cxx
index ef31fcf81282..36aa697b5071 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -2196,6 +2196,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);
@@ -2213,11 +2214,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 74c0f9514831..a3c1b92fe86d 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -673,8 +673,16 @@ void XclXmlUtils::GetFormulaTypeAndValue( ScFormulaCell& 
rCell, const char*& rsT
             rsValue = ToOUString(lcl_GetErrorString(aResValue.mnError));
         break;
         case sc::FormulaResultValue::Value:
-            rsType = "n";
-            rsValue = OUString::number(aResValue.mfValue);
+            if (rCell.GetFormatType() == SvNumFormatType::LOGICAL)
+            {
+                rsType = "b";
+                rsValue = rCell.GetValue() == 0.0 ? "0" : "1";
+            }
+            else
+            {
+                rsType = "n";
+                rsValue = OUString::number(aResValue.mfValue);
+            }
         break;
         case sc::FormulaResultValue::String:
             rsType = "str";
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);
     }
 }

Reply via email to