chart2/qa/extras/chart2import.cxx | 19 ++++++++++++++++++ chart2/qa/extras/charttest.hxx | 27 ++++++++++++++++++++++++++ chart2/qa/extras/data/docx/testTdf114179.docx |binary oox/source/drawingml/chart/converterbase.cxx | 8 ++++++- 4 files changed, 53 insertions(+), 1 deletion(-)
New commits: commit 26caf1bc59c81704f11225e3e431e412deb8c475 Author: Jozsef Szakacs <z...@citromail.hu> AuthorDate: Wed Nov 7 09:52:17 2018 +0100 Commit: Bartosz Kosiorek <gan...@poczta.onet.pl> CommitDate: Fri Nov 16 18:31:03 2018 +0100 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 <gan...@poczta.onet.pl> Tested-by: Bartosz Kosiorek <gan...@poczta.onet.pl> 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 new file mode 100644 index 000000000000..36fb11e170f7 Binary files /dev/null and b/chart2/qa/extras/data/docx/testTdf114179.docx differ diff --git a/oox/source/drawingml/chart/converterbase.cxx b/oox/source/drawingml/chart/converterbase.cxx index 678c3a4ba630..7faeb36576d1 100644 --- a/oox/source/drawingml/chart/converterbase.cxx +++ b/oox/source/drawingml/chart/converterbase.cxx @@ -39,6 +39,7 @@ #include <oox/token/tokens.hxx> #include <comphelper/processfactory.hxx> + namespace oox { namespace drawingml { namespace chart { @@ -349,7 +350,12 @@ bool LayoutConverter::calcAbsRectangle( awt::Rectangle& orRect ) const { if( !mrModel.mbAutoLayout ) { - const awt::Size& rChartSize = getChartSize(); + awt::Size rChartSize=getChartSize(); + if( (rChartSize.Width < 0) || (rChartSize.Height < 0) ) + { + rChartSize.Width = 16000; + rChartSize.Height = 9000; + } orRect.X = lclCalcPosition( rChartSize.Width, mrModel.mfX, mrModel.mnXMode ); orRect.Y = lclCalcPosition( rChartSize.Height, mrModel.mfY, mrModel.mnYMode ); if( (orRect.X >= 0) && (orRect.Y >= 0) ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits