summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2018-01-03 13:24:32 +0100
committerAndras Timar <andras.timar@collabora.com>2018-02-14 09:59:28 +0100
commit326c9766281e6f80abc042420f1d4be3a27b8aa9 (patch)
tree7c284290087ed15ba638217108ce45ce0ed93d81 /sd
parent615f4846751fb669ea28cc092eadfd3842ab3220 (diff)
tdf#114821 calculate better label position
Positioning hack was improved. It calculates position depending on direct chart size factor. Preffered label positions are: top - vertical, and center - horizontal Change-Id: Ic25f08cd0bc3105fe34841dbc3f8aacacb694d43 Reviewed-on: https://gerrit.libreoffice.org/48909 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/48928 Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/pptx/tdf114821.pptxbin0 -> 50235 bytes
-rw-r--r--sd/qa/unit/import-tests.cxx49
2 files changed, 49 insertions, 0 deletions
diff --git a/sd/qa/unit/data/pptx/tdf114821.pptx b/sd/qa/unit/data/pptx/tdf114821.pptx
new file mode 100644
index 000000000000..3813b0607903
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf114821.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index fd3b5721af27..2ab15a7763eb 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -56,6 +56,7 @@
#include <com/sun/star/animations/XAnimationNode.hpp>
#include <com/sun/star/animations/XAnimate.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/chart/DataLabelPlacement.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
@@ -165,6 +166,7 @@ public:
void testTdf109223();
void testActiveXCheckbox();
void testTdf108926();
+ void testTdf114821();
bool checkPattern(sd::DrawDocShellRef& rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
void testPatternImport();
@@ -237,6 +239,7 @@ public:
CPPUNIT_TEST(testTdf109223);
CPPUNIT_TEST(testActiveXCheckbox);
CPPUNIT_TEST(testTdf108926);
+ CPPUNIT_TEST(testTdf114821);
CPPUNIT_TEST_SUITE_END();
};
@@ -2313,6 +2316,52 @@ void SdImportTest::testTdf108926()
xDocShRef->DoClose();
}
+void SdImportTest::testTdf114821()
+{
+ css::uno::Any aAny;
+ sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc( "/sd/qa/unit/data/pptx/tdf114821.pptx" ), PPTX );
+
+ uno::Reference< beans::XPropertySet > xPropSet( getShapeFromPage( 0, 0, xDocShRef ) );
+ aAny = xPropSet->getPropertyValue( "Model" );
+ CPPUNIT_ASSERT_MESSAGE( "The shape doesn't have the property", aAny.hasValue() );
+
+ uno::Reference< chart::XChartDocument > xChartDoc;
+ aAny >>= xChartDoc;
+ CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChartDoc.is() );
+ uno::Reference< chart2::XChartDocument > xChart2Doc( xChartDoc, uno::UNO_QUERY );
+ CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart2Doc.is() );
+
+ uno::Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xChart2Doc->getFirstDiagram(), uno::UNO_QUERY );
+ uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xBCooSysCnt->getCoordinateSystems() );
+ uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[0], uno::UNO_QUERY );
+
+ uno::Reference< chart2::XDataSeriesContainer > xDSCnt( xCTCnt->getChartTypes()[0], uno::UNO_QUERY );
+ CPPUNIT_ASSERT_MESSAGE( "failed to load data series", xDSCnt.is() );
+ uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", static_cast<sal_Int32>( 1 ), aSeriesSeq.getLength() );
+
+ // Check the first label
+ const css::uno::Reference< css::beans::XPropertySet >& rPropSet0( aSeriesSeq[0]->getDataPointByIndex( 0 ) );
+ CPPUNIT_ASSERT( rPropSet0.is() );
+ sal_Int32 aPlacement;
+ rPropSet0->getPropertyValue( "LabelPlacement" ) >>= aPlacement;
+ CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::TOP, aPlacement );
+
+ // Check the second label
+ const css::uno::Reference< css::beans::XPropertySet >& rPropSet1( aSeriesSeq[0]->getDataPointByIndex( 1 ) );
+ CPPUNIT_ASSERT( rPropSet1.is() );
+ rPropSet1->getPropertyValue( "LabelPlacement" ) >>= aPlacement;
+ CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::CENTER, aPlacement );
+
+ // Check the third label
+ const css::uno::Reference< css::beans::XPropertySet >& rPropSet2( aSeriesSeq[0]->getDataPointByIndex( 2 ) );
+ CPPUNIT_ASSERT( rPropSet2.is() );
+ rPropSet2->getPropertyValue( "LabelPlacement") >>= aPlacement;
+ CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::TOP, aPlacement );
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();