From 93e4276addbaaf574e07f7f1a993c653c536645d Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Sun, 9 Mar 2014 18:38:02 -0400 Subject: fdo#75960: Write unit test for this. The window failed to launch ultimately due to failure of GetHeaderDim() call. Change-Id: I80c99a9ab1f33b4acee5324f417b7a3a26a91a22 --- .../data/ods/pivot-table-named-range-source.ods | Bin 0 -> 16927 bytes sc/qa/unit/subsequent_filters-test.cxx | 29 +++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 sc/qa/unit/data/ods/pivot-table-named-range-source.ods (limited to 'sc') diff --git a/sc/qa/unit/data/ods/pivot-table-named-range-source.ods b/sc/qa/unit/data/ods/pivot-table-named-range-source.ods new file mode 100644 index 000000000000..db3b96623cc4 Binary files /dev/null and b/sc/qa/unit/data/ods/pivot-table-named-range-source.ods differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 5336a5803da2..b34c1924b882 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -142,6 +142,7 @@ public: void testCellAnchoredShapesODS(); void testPivotTableBasicODS(); + void testPivotTableNamedRangeSourceODS(); void testPivotTableSharedCacheGroupODS(); void testGetPivotDataXLS(); @@ -210,6 +211,7 @@ public: CPPUNIT_TEST(testCellAnchoredShapesODS); CPPUNIT_TEST(testPivotTableBasicODS); + CPPUNIT_TEST(testPivotTableNamedRangeSourceODS); CPPUNIT_TEST(testPivotTableSharedCacheGroupODS); CPPUNIT_TEST(testGetPivotDataXLS); CPPUNIT_TEST(testRowHeightODS); @@ -1687,6 +1689,33 @@ void ScFiltersTest::testPivotTableBasicODS() xDocSh->DoClose(); } +void ScFiltersTest::testPivotTableNamedRangeSourceODS() +{ + ScDocShellRef xDocSh = loadDoc("pivot-table-named-range-source.", ODS); + CPPUNIT_ASSERT_MESSAGE("Failed to load pivot-table-named-range-source.ods", xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + + ScDPCollection* pDPs = pDoc->GetDPCollection(); + CPPUNIT_ASSERT(pDPs->GetCount() == 1); + + ScDPObject* pDP = (*pDPs)[0]; + CPPUNIT_ASSERT(pDP); + + // Make sure this pivot table is based on a named range source. + const ScSheetSourceDesc* pDesc = pDP->GetSheetDesc(); + CPPUNIT_ASSERT(pDesc); + CPPUNIT_ASSERT_EQUAL(OUString("MyRange"), pDesc->GetRangeName()); + + sal_uInt16 nOrient; + long nDim = pDP->GetHeaderDim(ScAddress(0,1,1), nOrient); + CPPUNIT_ASSERT_MESSAGE("Failed to detect header dimension.", nDim == 0); + CPPUNIT_ASSERT_MESSAGE("This dimension should be a page dimension.", + nOrient == sheet::DataPilotFieldOrientation_PAGE); + + xDocSh->DoClose(); +} + namespace { bool checkVisiblePageFieldMember( const ScDPSaveDimension::MemberList& rMembers, const OUString& rVisibleMember ) -- cgit