summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2022-02-28 15:36:08 +0200
committerAndras Timar <andras.timar@collabora.com>2022-03-09 09:17:19 +0100
commitc2d4c889ceab1e4a3d4d3d2cd2fb8be1b9050178 (patch)
tree3baa296d222d6be47e779547de0bf40719e08837 /sc/source
parent815fc96e2460a700f336283368618a88410a3056 (diff)
tdf#122471 xlsx import: pivottable error OUString, not uInt8
This fixes a LO 6.0 regression from commit 9fa34e9f2cebe2cfc551668f2a67ddcb799d3fb8 which only half-way changed to OUString from uInt8. An exception was raised because in XLSX, an INT was written while the corresponding read function was expecting an OUString. However, doing this runs into problems with binary files (xlsb), which were still setting the value to an int. Unit test shows the need to use OUString for xlsb too, which now matches what I see in Excel 2003. make CppunitTest_sc_pivottable_filters_test \ CPPUNIT_TEST_NAME=testPivotTableErrorItem2FilterXLSX Change-Id: I399c9e34984bb1ff71695a87aa56f53063d37b3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130714 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> (cherry picked from commit 6961f6732954742415413fa53bdeebd1b03d9ec5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130678 Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/filter/inc/pivotcachebuffer.hxx2
-rw-r--r--sc/source/filter/oox/pivotcachebuffer.cxx10
-rw-r--r--sc/source/filter/oox/pivotcachefragment.cxx2
3 files changed, 7 insertions, 7 deletions
diff --git a/sc/source/filter/inc/pivotcachebuffer.hxx b/sc/source/filter/inc/pivotcachebuffer.hxx
index 6f7e75a7151b..5997d8db3d2c 100644
--- a/sc/source/filter/inc/pivotcachebuffer.hxx
+++ b/sc/source/filter/inc/pivotcachebuffer.hxx
@@ -71,7 +71,7 @@ public:
/** Reads the boolean value from a pivot cache item. */
void readBool( SequenceInputStream& rStrm );
/** Reads the error code value from a pivot cache item. */
- void readError( SequenceInputStream& rStrm );
+ void readError(SequenceInputStream& rStrm, const UnitConverter& rUnitConverter);
/** Reads the index of a shared item. */
void readIndex( SequenceInputStream& rStrm );
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx b/sc/source/filter/oox/pivotcachebuffer.cxx
index 52c57d002a0b..b1b12ba435e8 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -202,9 +202,9 @@ void PivotCacheItem::readBool( SequenceInputStream& rStrm )
mnType = XML_b;
}
-void PivotCacheItem::readError( SequenceInputStream& rStrm )
+void PivotCacheItem::readError(SequenceInputStream& rStrm, const UnitConverter& rUnitConverter)
{
- maValue <<= static_cast< sal_Int32 >( rStrm.readuInt8() );
+ maValue <<= rUnitConverter.calcErrorString(rStrm.readuInt8());
mnType = XML_e;
}
@@ -294,7 +294,7 @@ void PivotCacheItemList::importItem( sal_Int32 nRecId, SequenceInputStream& rStr
case BIFF12_ID_PCITEM_BOOL:
case BIFF12_ID_PCITEMA_BOOL: rItem.readBool( rStrm ); break;
case BIFF12_ID_PCITEM_ERROR:
- case BIFF12_ID_PCITEMA_ERROR: rItem.readError( rStrm ); break;
+ case BIFF12_ID_PCITEMA_ERROR: rItem.readError(rStrm, getUnitConverter()); break;
default: OSL_FAIL( "PivotCacheItemList::importItem - unknown record type" );
}
}
@@ -339,7 +339,7 @@ void PivotCacheItemList::importArray( SequenceInputStream& rStrm )
{
case BIFF12_PCITEM_ARRAY_DOUBLE: createItem().readDouble( rStrm ); break;
case BIFF12_PCITEM_ARRAY_STRING: createItem().readString( rStrm ); break;
- case BIFF12_PCITEM_ARRAY_ERROR: createItem().readError( rStrm ); break;
+ case BIFF12_PCITEM_ARRAY_ERROR: createItem().readError(rStrm, getUnitConverter()); break;
case BIFF12_PCITEM_ARRAY_DATE: createItem().readDate( rStrm ); break;
default:
OSL_FAIL( "PivotCacheItemList::importArray - unknown data type" );
@@ -831,7 +831,7 @@ void PivotCacheField::writeItemToSourceDataCell( const WorksheetHelper& rSheetHe
case XML_i: rSheetData.setValueCell( aModel, rItem.getValue().get< sal_Int16 >() ); break;
case XML_d: rSheetData.setDateTimeCell( aModel, rItem.getValue().get< css::util::DateTime >() ); break;
case XML_b: rSheetData.setBooleanCell( aModel, rItem.getValue().get< bool >() ); break;
- case XML_e: rSheetData.setErrorCell( aModel, static_cast< sal_uInt8 >( rItem.getValue().get< sal_Int32 >() ) ); break;
+ case XML_e: rSheetData.setErrorCell(aModel, rItem.getValue().get<OUString>()); break;
default: OSL_FAIL( "PivotCacheField::writeItemToSourceDataCell - unexpected item data type" );
}
}
diff --git a/sc/source/filter/oox/pivotcachefragment.cxx b/sc/source/filter/oox/pivotcachefragment.cxx
index a8db4426be33..f508c36cf8cc 100644
--- a/sc/source/filter/oox/pivotcachefragment.cxx
+++ b/sc/source/filter/oox/pivotcachefragment.cxx
@@ -311,7 +311,7 @@ void PivotCacheRecordsFragment::importPCRecordItem( sal_Int32 nRecId, SequenceIn
case BIFF12_ID_PCITEM_DOUBLE: aItem.readDouble( rStrm ); break;
case BIFF12_ID_PCITEM_DATE: aItem.readDate( rStrm ); break;
case BIFF12_ID_PCITEM_BOOL: aItem.readBool( rStrm ); break;
- case BIFF12_ID_PCITEM_ERROR: aItem.readError( rStrm ); break;
+ case BIFF12_ID_PCITEM_ERROR: aItem.readError( rStrm, getUnitConverter() ); break;
case BIFF12_ID_PCITEM_INDEX: aItem.readIndex( rStrm ); break;
default: OSL_FAIL( "OoxPivotCacheRecordsFragment::importPCRecordItem - unexpected record" );
}