From 26caf1bc59c81704f11225e3e431e412deb8c475 Mon Sep 17 00:00:00 2001 From: Jozsef Szakacs Date: Wed, 7 Nov 2018 09:52:17 +0100 Subject: tdf#114179: Custom size and position of the chart wall By Xlsx files, rChartSize is using the Values that it gets from getChartSize(), this is the same Size as rPageSize. By Docx files rChartSize was a negative number everytime, so the calcAbsRectangle Method gave back a 'false' Value because of this. The rPageSize shows at every Debugging, Width = 16000, and Height = 9000 for Docx files, and beacause rChartSize was equal to rPageSize by Xlsx, I tried rChartSize with this Fixed Size. Change-Id: Ia29fa3401475c33c1b5e3dde9c3cb030a02cceb4 Reviewed-on: https://gerrit.libreoffice.org/62991 Reviewed-by: Bartosz Kosiorek Tested-by: Bartosz Kosiorek --- chart2/qa/extras/chart2import.cxx | 19 ++++++++++++++++++ chart2/qa/extras/charttest.hxx | 27 ++++++++++++++++++++++++++ chart2/qa/extras/data/docx/testTdf114179.docx | Bin 0 -> 5839 bytes 3 files changed, 46 insertions(+) create mode 100644 chart2/qa/extras/data/docx/testTdf114179.docx (limited to 'chart2/qa') diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index e478dbb66803..f9d5343c0317 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -111,8 +111,11 @@ public: void testTdf115107_2(); // import complex data point labels in cobo charts with multiple data series void testTdf116163(); + void testTdf121205(); + void testTdf114179(); + CPPUNIT_TEST_SUITE(Chart2ImportTest); CPPUNIT_TEST(Fdo60083); CPPUNIT_TEST(testSteppedLines); @@ -177,8 +180,11 @@ public: CPPUNIT_TEST(testTdf115107_2); CPPUNIT_TEST(testTdf116163); + CPPUNIT_TEST(testTdf121205); + CPPUNIT_TEST(testTdf114179); + CPPUNIT_TEST_SUITE_END(); private: @@ -1598,6 +1604,19 @@ void Chart2ImportTest::testTdf121205() CPPUNIT_ASSERT_EQUAL(OUString("Firstline\nSecondline\nThirdline"), aTitle); } +void Chart2ImportTest::testTdf114179() +{ + load( "/chart2/qa/extras/data/docx/", "testTdf114179.docx" ); + uno::Reference< chart2::XChartDocument > xChartDoc ( getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT( xChartDoc.is() ); + css::uno::Reference xDiagram; + xDiagram.set( xChartDoc->getFirstDiagram() ); + CPPUNIT_ASSERT_MESSAGE( "There is a Diagram." , xDiagram.is() ); + awt::Size aPage = getPageSize( xChartDoc ); + awt::Size aSize = getSize( xDiagram,aPage ); + CPPUNIT_ASSERT( aSize.Width > 0); + CPPUNIT_ASSERT( aSize.Height > 0); +} CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest); diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index 202475e7e4ca..84cea90845c3 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -65,6 +65,9 @@ #include #include +#include +#include +#include using namespace css; using namespace css::uno; @@ -84,6 +87,8 @@ public: uno::Reference getChartDocFromDrawImpress( sal_Int32 nPage, sal_Int32 nShape ); uno::Reference getChartDocFromWriter( sal_Int32 nShape ); + awt::Size getPageSize( const Reference< chart2::XChartDocument > & xChartDoc ); + awt::Size getSize(css::uno::Reference xDiagram, const awt::Size& rPageSize); virtual void setUp() override; virtual void tearDown() override; @@ -590,6 +595,28 @@ sal_Int16 getNumberFormatType( const Reference& xChartDo return nType; } +awt::Size ChartTest::getPageSize( const Reference< chart2::XChartDocument > & xChartDoc ) +{ + awt::Size aSize( 0, 0 ); + uno::Reference< com::sun::star::embed::XVisualObject > xVisualObject( xChartDoc, uno::UNO_QUERY ); + CPPUNIT_ASSERT( xVisualObject.is() ); + aSize = xVisualObject->getVisualAreaSize( com::sun::star::embed::Aspects::MSOLE_CONTENT ); +return aSize; +} + +awt::Size ChartTest::getSize(css::uno::Reference xDiagram, const awt::Size& rPageSize) +{ + Reference< beans::XPropertySet > xProp(xDiagram, uno::UNO_QUERY); + chart2::RelativeSize aRelativeSize; + xProp->getPropertyValue( "RelativeSize" ) >>= aRelativeSize; + double fX = aRelativeSize.Primary * rPageSize.Width; + double fY = aRelativeSize.Secondary * rPageSize.Height; + awt::Size aSize; + aSize.Width = static_cast< sal_Int32 >( ::rtl::math::round( fX ) ); + aSize.Height = static_cast< sal_Int32 >( ::rtl::math::round( fY ) ); + return aSize; +} + #endif // INCLUDED_CHART2_QA_EXTRAS_CHARTTEST_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/qa/extras/data/docx/testTdf114179.docx b/chart2/qa/extras/data/docx/testTdf114179.docx new file mode 100644 index 000000000000..36fb11e170f7 Binary files /dev/null and b/chart2/qa/extras/data/docx/testTdf114179.docx differ -- cgit