diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2021-08-25 14:40:24 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-09-01 10:31:54 +0200 |
commit | 9fbe0a171ece07da0d5c1e16eae23a167cb81114 (patch) | |
tree | 4ee35708516fbc1cb8489182a2139e78f338b023 /chart2 | |
parent | 504d78acb866495fd954fcd6db22ea68f174a5ab (diff) |
tdf#143127 tdf#143130 ooxml export: fix lost image/shape in chart
tdf#143127: Add officeRel namespace to XML_userShapes
to fix invalid file error in MSO.
tdf#143130: Add mbUserShapes variable to ShapeExport class
to fix export of embedded shapes of charts in DOCX.
Change-Id: I10c1dbf905af96d6a63a9243514b32a6440e63f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121035
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/qa/extras/chart2export2.cxx | 61 | ||||
-rw-r--r-- | chart2/qa/extras/data/docx/tdf143130.docx | bin | 0 -> 26675 bytes | |||
-rw-r--r-- | chart2/qa/extras/data/xlsx/tdf143127.xlsx | bin | 0 -> 18486 bytes |
3 files changed, 61 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2export2.cxx b/chart2/qa/extras/chart2export2.cxx index 3a1afef91bd6..d7862946fd4d 100644 --- a/chart2/qa/extras/chart2export2.cxx +++ b/chart2/qa/extras/chart2export2.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/chart2/DataPointLabel.hpp> #include <com/sun/star/chart/DataLabelPlacement.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> #include <libxml/xpathInternals.h> @@ -97,6 +98,8 @@ public: void testTdf138181(); void testCustomShapeText(); void testuserShapesXLSX(); + void testuserShapesDOCX(); + void testGraphicBlipXLSX(); void testNameRangeXLSX(); void testTdf143942(); @@ -159,6 +162,8 @@ public: CPPUNIT_TEST(testTdf138181); CPPUNIT_TEST(testCustomShapeText); CPPUNIT_TEST(testuserShapesXLSX); + CPPUNIT_TEST(testuserShapesDOCX); + CPPUNIT_TEST(testGraphicBlipXLSX); CPPUNIT_TEST(testNameRangeXLSX); CPPUNIT_TEST(testTdf143942); CPPUNIT_TEST_SUITE_END(); @@ -1462,6 +1467,62 @@ void Chart2ExportTest2::testuserShapesXLSX() CPPUNIT_ASSERT(!xRange->getString().isEmpty()); } +void Chart2ExportTest2::testuserShapesDOCX() +{ + load(u"/chart2/qa/extras/data/docx/", "tdf143130.docx"); + reload("Office Open XML Text"); + + Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + // test that the custom shape exists + Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference<drawing::XShape> xCustomShape(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + CPPUNIT_ASSERT(xCustomShape.is()); + // test type of shape + CPPUNIT_ASSERT(xCustomShape->getShapeType().endsWith("CustomShape")); + // test custom shape position + awt::Point aPosition = xCustomShape->getPosition(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(9824, aPosition.X, 300); + CPPUNIT_ASSERT_DOUBLES_EQUAL(547, aPosition.Y, 300); + // test custom shape size + awt::Size aSize = xCustomShape->getSize(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1848, aSize.Width, 300); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1003, aSize.Height, 300); + // test custom shape text + Reference<text::XText> xRange(xCustomShape, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(!xRange->getString().isEmpty()); +} + +void Chart2ExportTest2::testGraphicBlipXLSX() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf143127.xlsx"); + reload("Calc Office Open XML"); + + Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + + // test that the Graphic shape exists + Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference<drawing::XShape> xCustomShape(xDrawPage->getByIndex(1), UNO_QUERY_THROW); + CPPUNIT_ASSERT(xCustomShape.is()); + // test type of shape + CPPUNIT_ASSERT(xCustomShape->getShapeType().endsWith("GraphicObjectShape")); + Reference<XPropertySet> xShapeProps(xCustomShape, UNO_QUERY); + + uno::Reference<graphic::XGraphic> xGraphic; + CPPUNIT_ASSERT(xShapeProps->getPropertyValue("Graphic") >>= xGraphic); + + Graphic aGraphic(xGraphic); + GfxLink aLink = aGraphic.GetGfxLink(); + std::size_t nDataSize = aLink.GetDataSize(); + + // test the image size is bigger then 0. + CPPUNIT_ASSERT_GREATER(size_t(0), nDataSize); +} + void Chart2ExportTest2::testNameRangeXLSX() { load(u"/chart2/qa/extras/data/xlsx/", "chart_with_name_range.xlsx"); diff --git a/chart2/qa/extras/data/docx/tdf143130.docx b/chart2/qa/extras/data/docx/tdf143130.docx Binary files differnew file mode 100644 index 000000000000..a364f4811a9f --- /dev/null +++ b/chart2/qa/extras/data/docx/tdf143130.docx diff --git a/chart2/qa/extras/data/xlsx/tdf143127.xlsx b/chart2/qa/extras/data/xlsx/tdf143127.xlsx Binary files differnew file mode 100644 index 000000000000..116a00b60c35 --- /dev/null +++ b/chart2/qa/extras/data/xlsx/tdf143127.xlsx |