diff --git a/sc/qa/unit/data/xlsx/tdf112106.xlsx b/sc/qa/unit/data/xlsx/tdf112106.xlsx new file mode 100755 index 000000000000..37203d1dbd5b Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf112106.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 60e870412c5b..79221e9c85f4 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -46,6 +46,8 @@ #include #include "validat.hxx" #include +#include "globstr.hrc" +#include "global.hxx" #include #include @@ -207,6 +209,7 @@ public: void testHiddenRepeatedRowsODS(); void testHyperlinkTargetFrameODS(); + void testTdf112106(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -310,6 +313,7 @@ public: CPPUNIT_TEST(testHiddenRepeatedRowsODS); CPPUNIT_TEST(testHyperlinkTargetFrameODS); + CPPUNIT_TEST(testTdf112106); CPPUNIT_TEST_SUITE_END(); private: @@ -4258,6 +4262,35 @@ void ScExportTest::testPivotTableRowHeaderXLS() xDocSh->DoClose(); } +void ScExportTest::testTdf112106() +{ + ScDocShellRef xDocSh = loadDoc("tdf112106.", FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + ScDPCollection* pDPs = rDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), pDPs->GetCount()); + + // Reload and check data layout dim + xDocSh = saveAndReload( &(*xDocSh), FORMAT_XLS); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rLoadedDoc = xDocSh->GetDocument(); + pDPs = rLoadedDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), pDPs->GetCount()); + const ScDPObject* pDPObj = &(*pDPs)[0]; + CPPUNIT_ASSERT(pDPObj); + const ScDPSaveData* pSaveData = pDPObj->GetSaveData(); + CPPUNIT_ASSERT(pSaveData); + + // Check that we have an existing data layout dimension + const ScDPSaveDimension* pDim = pSaveData->GetExistingDataLayoutDimension(); + CPPUNIT_ASSERT(pDim); + const OUString* pLayoutName = pDim->GetLayoutName(); + CPPUNIT_ASSERT(pLayoutName); + CPPUNIT_ASSERT_EQUAL(ScGlobal::GetRscString(STR_PIVOT_DATA), (*pLayoutName)); + + xDocSh->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx index 171837c8cac5..d28348aabf0b 100644 --- a/sc/source/filter/excel/xepivot.cxx +++ b/sc/source/filter/excel/xepivot.cxx @@ -1304,10 +1304,8 @@ void XclExpPivotTable::SetPropertiesFromDP( const ScDPSaveData& rSaveData ) ::set_flag( maPTExtInfo.mnFlags, EXC_SXEX_DRILLDOWN, rSaveData.GetDrillDown() ); mbFilterBtn = rSaveData.GetFilterButton(); const ScDPSaveDimension* pDim = rSaveData.GetExistingDataLayoutDimension(); - if (!pDim) - return; - const OUString* pLayoutName = pDim->GetLayoutName(); + const OUString* pLayoutName = pDim ? pDim->GetLayoutName() : nullptr; if (pLayoutName) maPTInfo.maDataName = *pLayoutName; else