[Libreoffice-commits] core.git: 2 commits - chart2/qa oox/source

Markus Mohrhard markus.mohrhard at googlemail.com
Sat Apr 25 06:22:38 PDT 2015


 chart2/qa/extras/chart2export.cxx                    |   21 ++++++++++++
 chart2/qa/extras/data/xlsx/legend_manual_layout.xlsx |binary
 oox/source/export/chartexport.cxx                    |   33 +++++++++++++++++++
 3 files changed, 54 insertions(+)

New commits:
commit 3aec78edd7e36a950866a91060f85cfcd3b4fbdd
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Apr 25 15:19:10 2015 +0200

    add test for tdf#88848
    
    Change-Id: I1ad26038db7ee386d7d6dc333e29845753ab8ec3

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 2535dcb..f087463 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -92,6 +92,7 @@ public:
     void testNoMarkerXLSX();
     void testTitleManualLayoutXLSX();
     void testPlotAreaManualLayoutXLSX();
+    void testLegendManualLayoutXLSX();
 
     CPPUNIT_TEST_SUITE(Chart2ExportTest);
     CPPUNIT_TEST(testErrorBarXLSX);
@@ -148,6 +149,7 @@ public:
     CPPUNIT_TEST(testNoMarkerXLSX);
     CPPUNIT_TEST(testTitleManualLayoutXLSX);
     CPPUNIT_TEST(testPlotAreaManualLayoutXLSX);
+    CPPUNIT_TEST(testLegendManualLayoutXLSX);
     CPPUNIT_TEST_SUITE_END();
 
 protected:
@@ -1368,6 +1370,25 @@ void Chart2ExportTest::testPlotAreaManualLayoutXLSX()
     CPPUNIT_ASSERT(nH != nW);
 }
 
+void Chart2ExportTest::testLegendManualLayoutXLSX()
+{
+    load("/chart2/qa/extras/data/xlsx/", "legend_manual_layout.xlsx");
+    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:xMode", "val", "edge");
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:yMode", "val", "edge");
+
+    OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:x", "val");
+    double nX = aXVal.toDouble();
+    CPPUNIT_ASSERT(nX > 0 && nX < 1);
+
+    OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:y", "val");
+    double nY = aYVal.toDouble();
+    CPPUNIT_ASSERT(nY > 0 && nY < 1);
+    CPPUNIT_ASSERT(nX != nY);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/xlsx/legend_manual_layout.xlsx b/chart2/qa/extras/data/xlsx/legend_manual_layout.xlsx
new file mode 100644
index 0000000..16ea011
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/legend_manual_layout.xlsx differ
commit 0afab16d9afb8ccd1f089447868b25a960ec595b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Apr 25 15:00:30 2015 +0200

    support manualLayout for legends OOXML export, tdf#88848
    
    Change-Id: If7ac2a2294e20617fd8b599597085658051f5515

diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index e0f8745..263db8d 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -996,6 +996,39 @@ void ChartExport::exportLegend( Reference< css::chart::XChartDocument > rChartDo
             pFS->singleElement( FSNS( XML_c, XML_legendPos ),
                 XML_val, strPos,
                 FSEND );
+        }
+
+        uno::Any aRelativePos = xProp->getPropertyValue("RelativePosition");
+        if (aRelativePos.hasValue())
+        {
+            chart2::RelativePosition aPos = aRelativePos.get<chart2::RelativePosition>();
+            pFS->startElement(FSNS(XML_c, XML_layout), FSEND);
+            pFS->startElement(FSNS(XML_c, XML_manualLayout), FSEND);
+
+            pFS->singleElement(FSNS(XML_c, XML_xMode),
+                    XML_val, "edge",
+                    FSEND);
+            pFS->singleElement(FSNS(XML_c, XML_yMode),
+                    XML_val, "edge",
+                    FSEND);
+
+            double x = aPos.Primary;
+            double y = aPos.Secondary;
+
+            pFS->singleElement(FSNS(XML_c, XML_x),
+                    XML_val, IS(x),
+                    FSEND);
+            pFS->singleElement(FSNS(XML_c, XML_y),
+                    XML_val, IS(y),
+                    FSEND);
+            SAL_WARN_IF(aPos.Anchor != 0, "oox.chart", "unsupported anchor position");
+
+            pFS->endElement(FSNS(XML_c, XML_manualLayout));
+            pFS->endElement(FSNS(XML_c, XML_layout));
+        }
+
+        if (strPos != NULL)
+        {
             pFS->singleElement( FSNS( XML_c, XML_overlay ),
                     XML_val, "0",
                     FSEND );


More information about the Libreoffice-commits mailing list