Kaydet (Commit) 26caf1bc authored tarafından Jozsef Szakacs's avatar Jozsef Szakacs Kaydeden (comit) Bartosz Kosiorek

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/62991Reviewed-by: 's avatarBartosz Kosiorek <gang65@poczta.onet.pl>
Tested-by: 's avatarBartosz Kosiorek <gang65@poczta.onet.pl>
üst cb1d625a
......@@ -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);
......
......@@ -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: */
......@@ -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) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment