From 071a36e042c76286fedb38f479dac79f29b661f9 Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Mon, 8 Aug 2022 18:56:04 +0200 Subject: tdf#150176 pptx chart import: fix automatic border style Do not set the default border style for chart area in case of pptx charts, if it is came from the MSO as an automtic line style. regression from commit: 0dac43445b35da7e554dd4d7574c59611a0d0be1 (tdf#81437 XLSX import: fix missing chart border) Change-Id: Iaaaecc1dffe80c3f1528851e707236f2f7228bee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137993 Tested-by: Jenkins Reviewed-by: Balazs Varga --- chart2/qa/extras/chart2import.cxx | 16 ++++++++++++++++ chart2/qa/extras/data/pptx/tdf150176.pptx | Bin 0 -> 52342 bytes oox/source/drawingml/chart/objectformatter.cxx | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 chart2/qa/extras/data/pptx/tdf150176.pptx diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 316520fb5197..4e5b3a83130e 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -85,6 +85,7 @@ public: void testTdf126033(); void testAutoBackgroundXLSX(); void testAutoChartAreaBorderPropXLSX(); + void testAutoChartAreaBorderPropPPTX(); void testChartAreaStyleBackgroundXLSX(); void testChartHatchFillXLSX(); void testAxisTextRotationXLSX(); @@ -178,6 +179,7 @@ public: CPPUNIT_TEST(testTdf126033); CPPUNIT_TEST(testAutoBackgroundXLSX); CPPUNIT_TEST(testAutoChartAreaBorderPropXLSX); + CPPUNIT_TEST(testAutoChartAreaBorderPropPPTX); CPPUNIT_TEST(testChartAreaStyleBackgroundXLSX); CPPUNIT_TEST(testChartHatchFillXLSX); CPPUNIT_TEST(testAxisTextRotationXLSX); @@ -1106,6 +1108,20 @@ void Chart2ImportTest::testAutoChartAreaBorderPropXLSX() sal_Int32(26), nWidth); } +void Chart2ImportTest::testAutoChartAreaBorderPropPPTX() +{ + load(u"/chart2/qa/extras/data/pptx/", u"tdf150176.pptx"); + Reference xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + + // Test "Automatic" chartarea border style/color/width. + Reference xPropSet = xChartDoc->getPageBackground(); + CPPUNIT_ASSERT(xPropSet.is()); + drawing::LineStyle eStyle = xPropSet->getPropertyValue("LineStyle").get(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border should be loaded as none style for pptx.", + drawing::LineStyle_NONE, eStyle); +} + void Chart2ImportTest::testChartAreaStyleBackgroundXLSX() { load(u"/chart2/qa/extras/data/xlsx/", u"chart-area-style-background.xlsx"); diff --git a/chart2/qa/extras/data/pptx/tdf150176.pptx b/chart2/qa/extras/data/pptx/tdf150176.pptx new file mode 100644 index 000000000000..fa217f92c822 Binary files /dev/null and b/chart2/qa/extras/data/pptx/tdf150176.pptx differ diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index 14c96d166a03..5644b9eedf09 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -829,8 +829,8 @@ LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() ) if( const LineProperties* pLineProps = pTheme->getLineStyle( pAutoFormatEntry->mnThemedIdx ) ) *mxAutoLine = *pLineProps; - // set automatic border property for chartarea, because of tdf#81437 and tdf#82217 - if ( eObjType == OBJECTTYPE_CHARTSPACE ) + // set automatic border property for chartarea, because of tdf#81437 and tdf#82217, except for pptx (tdf#150176) + if ( eObjType == OBJECTTYPE_CHARTSPACE && !rData.mrFilter.getFileUrl().endsWithIgnoreAsciiCase(".pptx") ) { mxAutoLine->maLineFill.moFillType = oox::GraphicHelper::getDefaultChartAreaLineStyle(); mxAutoLine->moLineWidth = oox::GraphicHelper::getDefaultChartAreaLineWidth(); -- cgit v1.2.3