chart2/qa/extras/chart2export.cxx | 22 ++++++ chart2/qa/extras/data/xlsx/title_manual_layout.xlsx |binary oox/source/export/chartexport.cxx | 73 +++++++++++++++++++- 3 files changed, 92 insertions(+), 3 deletions(-)
New commits: commit e9fbe1f7cd28de2a9da8089d89e903406165eb56 Author: Markus Mohrhard <[email protected]> Date: Sat Apr 25 02:14:21 2015 +0200 also add a test case for title rotation, tdf#75015 Change-Id: Ie83b4fb4d7ae8a8b752dcacdaff00bfce0c72ed9 diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index fcc91a2..00bec71 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -1334,6 +1334,8 @@ void Chart2ExportTest::testTitleManualLayoutXLSX() double nY = aYVal.toDouble(); CPPUNIT_ASSERT(nY > 0 && nY < 1); CPPUNIT_ASSERT(nX != nY); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:bodyPr", "rot", "1200000"); } CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest); commit af46ffafb73ff305e53be8768033d69ca9e6e5e1 Author: Markus Mohrhard <[email protected]> Date: Sat Apr 25 01:54:07 2015 +0200 add test for tdf#75015 Change-Id: Idb1cbb9bf016d102705089b44486810affe7e3b0 diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 87b7032..fcc91a2 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -90,6 +90,7 @@ public: void testInvertIfNegativeXLSX(); void testBubble3DXLSX(); void testNoMarkerXLSX(); + void testTitleManualLayoutXLSX(); CPPUNIT_TEST_SUITE(Chart2ExportTest); CPPUNIT_TEST(testErrorBarXLSX); @@ -144,6 +145,7 @@ public: CPPUNIT_TEST(testInvertIfNegativeXLSX); CPPUNIT_TEST(testBubble3DXLSX); CPPUNIT_TEST(testNoMarkerXLSX); + CPPUNIT_TEST(testTitleManualLayoutXLSX); CPPUNIT_TEST_SUITE_END(); protected: @@ -1316,6 +1318,24 @@ void Chart2ExportTest::testNoMarkerXLSX() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:marker", "val", "0"); } +void Chart2ExportTest::testTitleManualLayoutXLSX() +{ + load("/chart2/qa/extras/data/xlsx/", "title_manual_layout.xlsx"); + xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:xMode", "val", "edge"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:yMode", "val", "edge"); + + OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/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:title/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/title_manual_layout.xlsx b/chart2/qa/extras/data/xlsx/title_manual_layout.xlsx new file mode 100644 index 0000000..c89b2af Binary files /dev/null and b/chart2/qa/extras/data/xlsx/title_manual_layout.xlsx differ commit d55cb0845a094601dcc0149e9a59e360021d231c Author: Markus Mohrhard <[email protected]> Date: Sat Apr 25 01:23:36 2015 +0200 export title rotation, tdf#75015 Change-Id: I4ab3aeefb7ce58786a034798aa09b92a81791770 diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index e53540e..80bcfba 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1011,6 +1011,26 @@ void ChartExport::exportLegend( Reference< ::com::sun::star::chart::XChartDocume pFS->endElement( FSNS( XML_c, XML_legend ) ); } +namespace { + +/** + * nRotation is a 100th of a degree and the return value is + * in a 60,000th of a degree + * + * Also rotation is in opposite directions so multiply with -1 + */ +OString calcRotationValue(sal_Int32 nRotation) +{ + if (nRotation > 18000) // 180 degree + { + nRotation -= 36000; + } + nRotation *= -600; + return OString::number(nRotation); +} + +} + void ChartExport::exportTitle( Reference< XShape > xShape ) { OUString sText; @@ -1038,8 +1058,12 @@ void ChartExport::exportTitle( Reference< XShape > xShape ) if( bVertical ) sWritingMode = "wordArtVert"; + sal_Int32 nRotation; + xPropSet->getPropertyValue("TextRotation") >>= nRotation; + pFS->singleElement( FSNS( XML_a, XML_bodyPr ), XML_vert, sWritingMode, + XML_rot, nRotation == 0 ? NULL : calcRotationValue(nRotation).getStr(), FSEND ); // TODO: lstStyle pFS->singleElement( FSNS( XML_a, XML_lstStyle ), commit bee3934bb68f38e89bb33f75f405099ca08d59a9 Author: Markus Mohrhard <[email protected]> Date: Sat Apr 25 00:51:37 2015 +0200 first part for axis title manual position export, tdf#75015 Change-Id: Ib49ea2e76805e68ff71a52d9308258969454aaca diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 5a51066..e53540e 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -83,6 +83,8 @@ #include <com/sun/star/text/WritingMode.hpp> #include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/embed/XVisualObject.hpp> +#include <com/sun/star/embed/Aspects.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/random.hxx> @@ -1066,9 +1068,50 @@ void ChartExport::exportTitle( Reference< XShape > xShape ) pFS->endElement( FSNS( XML_c, XML_rich ) ); pFS->endElement( FSNS( XML_c, XML_tx ) ); - // TODO:customize layout - pFS->singleElement( FSNS( XML_c, XML_layout ), - FSEND ); + uno::Any aManualLayout = xPropSet->getPropertyValue("RelativePosition"); + if (aManualLayout.hasValue()) + { + 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); + + Reference<embed::XVisualObject> xVisObject(mxChartModel, uno::UNO_QUERY); + awt::Size aPageSize = xVisObject->getVisualAreaSize(embed::Aspects::MSOLE_CONTENT); + + // awt::Size aSize = xShape->getSize(); + awt::Point aPos2 = xShape->getPosition(); + double x = (double)aPos2.X / (double) aPageSize.Width; + double y = (double)aPos2.Y / (double) aPageSize.Height; + /* + pFS->singleElement(FSNS(XML_c, XML_wMode), + XML_val, "edge", + FSEND); + pFS->singleElement(FSNS(XML_c, XML_hMode), + XML_val, "edge", + FSEND); + */ + pFS->singleElement(FSNS(XML_c, XML_x), + XML_val, IS(x), + FSEND); + pFS->singleElement(FSNS(XML_c, XML_y), + XML_val, IS(y), + FSEND); + /* + pFS->singleElement(FSNS(XML_c, XML_w), + XML_val, "", + FSEND); + pFS->singleElement(FSNS(XML_c, XML_h), + XML_val, "", + FSEND); + */ + pFS->endElement(FSNS(XML_c, XML_manualLayout)); + pFS->endElement(FSNS(XML_c, XML_layout)); + } pFS->singleElement( FSNS(XML_c, XML_overlay), XML_val, "0", _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
