[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - chart2/qa oox/source

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 1 14:40:25 UTC 2021


 chart2/qa/extras/chart2import.cxx                  |   19 +++++++++++++++++++
 chart2/qa/extras/data/docx/testcustomshapepos.docx |binary
 oox/source/drawingml/chart/chartspaceconverter.cxx |    6 +++++-
 3 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit 0b3a7e6f1d704c3014986c0f0bccde060e96fa90
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Thu Nov 26 17:44:24 2020 +0100
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Mon Mar 1 15:39:51 2021 +0100

    tdf#138561 OOXML Chart import: fix custom shape position
    
    and size within charts. Use default page size for custom
    shapes, too, like in the case of other shapes (legend, titles,
    etc.), until we get the actual size of the embedded chart.
    
    Follow up commit: a01ccdfa5fd5a0260b7aedf955e1e5aa0df072c3
    (tdf#138307 Chart import: fix disappeared text from custom shape)
    
    Change-Id: Id6da7322326fbe8dfa570264107db59cc45dff31
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106704
    Reviewed-by: Balazs Varga <varga.balazs3 at nisz.hu>
    Tested-by: Balazs Varga <varga.balazs3 at nisz.hu>
    (cherry picked from commit f1a5bb0b79c212a0459b1a17dd15f1159e663dbd)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106820
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
    (cherry picked from commit 48ad658a7aacf849e773aa5d3400540d81f988f2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111708
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index cb319ae08928..cfd5b87c6f34 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -165,6 +165,7 @@ public:
     void testTdf91250();
     void testTdf134111();
     void testTdf137505();
+    void testTdfCustomShapePos();
 
     CPPUNIT_TEST_SUITE(Chart2ImportTest);
     CPPUNIT_TEST(Fdo60083);
@@ -278,6 +279,7 @@ public:
     CPPUNIT_TEST(testTdf91250);
     CPPUNIT_TEST(testTdf134111);
     CPPUNIT_TEST(testTdf137505);
+    CPPUNIT_TEST(testTdfCustomShapePos);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -2637,6 +2639,23 @@ void Chart2ImportTest::testTdf137505()
     CPPUNIT_ASSERT_EQUAL(float(12), nFontSize);
 }
 
+void Chart2ImportTest::testTdfCustomShapePos()
+{
+    load("/chart2/qa/extras/data/docx/", "testcustomshapepos.docx");
+    Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), UNO_QUERY_THROW);
+    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);
+
+    // test position and size of a custom shape within a chart
+    awt::Point aPosition = xCustomShape->getPosition();
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(8845, aPosition.X, 300);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(855, aPosition.Y, 300);
+    awt::Size aSize = xCustomShape->getSize();
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(4831, aSize.Width, 300);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1550, aSize.Height, 300);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/docx/testcustomshapepos.docx b/chart2/qa/extras/data/docx/testcustomshapepos.docx
new file mode 100644
index 000000000000..31c5284e11b9
Binary files /dev/null and b/chart2/qa/extras/data/docx/testcustomshapepos.docx differ
diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx b/oox/source/drawingml/chart/chartspaceconverter.cxx
index 1f90c2e092eb..d33e0086cc08 100644
--- a/oox/source/drawingml/chart/chartspaceconverter.cxx
+++ b/oox/source/drawingml/chart/chartspaceconverter.cxx
@@ -275,9 +275,13 @@ void ChartSpaceConverter::convertFromModel( const Reference< XShapes >& rxExtern
             drawing page instead, it is not possible to embed OLE objects. */
         bool bOleSupport = rxExternalPage.is();
 
+        awt::Size aChartSize = getChartSize();
+        if( aChartSize.Width <= 0 || aChartSize.Height <= 0 )
+            aChartSize = getDefaultPageSize();
+
         // now, xShapes is not null anymore
         getFilter().importFragment( new ChartDrawingFragment(
-            getFilter(), mrModel.maDrawingPath, xShapes, getChartSize(), aShapesOffset, bOleSupport ) );
+            getFilter(), mrModel.maDrawingPath, xShapes, aChartSize, aShapesOffset, bOleSupport ) );
     }
     catch( Exception& )
     {


More information about the Libreoffice-commits mailing list