diff options
author | Jozsef Szakacs <zmx3@citromail.hu> | 2018-11-07 09:52:17 +0100 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2018-11-16 18:31:03 +0100 |
commit | 26caf1bc59c81704f11225e3e431e412deb8c475 (patch) | |
tree | 2bff1302475fcf09da9afb5d95961bc66b0f8830 /chart2 | |
parent | cb1d625aee558c9aa3c0bf3ea44b65f37dca48a8 (diff) |
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 <gang65@poczta.onet.pl>
Tested-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/qa/extras/chart2import.cxx | 19 | ||||
-rw-r--r-- | chart2/qa/extras/charttest.hxx | 27 | ||||
-rw-r--r-- | chart2/qa/extras/data/docx/testTdf114179.docx | bin | 0 -> 5839 bytes |
3 files changed, 46 insertions, 0 deletions
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<chart2::XDiagram> 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 <libxml/xmlwriter.h> #include <libxml/xpath.h> +#include <com/sun/star/embed/Aspects.hpp> +#include <com/sun/star/embed/XVisualObject.hpp> +#include <com/sun/star/chart2/RelativeSize.hpp> using namespace css; using namespace css::uno; @@ -84,6 +87,8 @@ public: uno::Reference<chart::XChartDocument> getChartDocFromDrawImpress( sal_Int32 nPage, sal_Int32 nShape ); uno::Reference<chart::XChartDocument> getChartDocFromWriter( sal_Int32 nShape ); + awt::Size getPageSize( const Reference< chart2::XChartDocument > & xChartDoc ); + awt::Size getSize(css::uno::Reference<chart2::XDiagram> xDiagram, const awt::Size& rPageSize); virtual void setUp() override; virtual void tearDown() override; @@ -590,6 +595,28 @@ sal_Int16 getNumberFormatType( const Reference<chart2::XChartDocument>& 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<chart2::XDiagram> 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 Binary files differnew file mode 100644 index 000000000000..36fb11e170f7 --- /dev/null +++ b/chart2/qa/extras/data/docx/testTdf114179.docx |