summaryrefslogtreecommitdiff
path: root/chart2/qa
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.co.uk>2017-07-31 10:52:55 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-08-02 07:44:58 +0200
commitd8e731adb8608aab17385e02f4441ed3122efa40 (patch)
tree52c3a694d6d4e768ace0fdfe6cd87285665218ab /chart2/qa
parent95c2f226b122c7fdb77c6e9085b1fbd02189db03 (diff)
tdf#90352: set/handle LinkNumberFormatToSource property in xls...
Import/Export filter respectively for axis numbers. For ods and xlsx this was already getting set/handled correctly. Also add unit test to assert LinkNumberFormatToSource property and number format for import and export-import roundtrip. Change-Id: Id029ac7d0233ca490a6a00609e9cea8fdafee70f Reviewed-on: https://gerrit.libreoffice.org/40577 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'chart2/qa')
-rw-r--r--chart2/qa/extras/chart2export.cxx61
-rw-r--r--chart2/qa/extras/data/xls/axis_sourceformatting.xlsbin0 -> 7168 bytes
2 files changed, 61 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index d9050f858c2c..67aa996c89d5 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -71,6 +71,7 @@ public:
void testFdo78290ScatterChartMarkerX();
void testFdo78290CombinationChartMarkerX();
void testAxisNumberFormatODS();
+ void testAxisNumberFormatXLS();
void testDataLabelBordersDOCX();
void testDataLabel3DChartDOCX();
void testDataLabelBarChartDOCX();
@@ -135,6 +136,7 @@ public:
CPPUNIT_TEST(testFdo78290ScatterChartMarkerX);
CPPUNIT_TEST(testFdo78290CombinationChartMarkerX);
CPPUNIT_TEST(testAxisNumberFormatODS);
+ CPPUNIT_TEST(testAxisNumberFormatXLS);
CPPUNIT_TEST(testDataLabelBordersDOCX);
CPPUNIT_TEST(testDataLabel3DChartDOCX);
CPPUNIT_TEST(testDataLabelBarChartDOCX);
@@ -758,6 +760,65 @@ void Chart2ExportTest::testAxisNumberFormatODS()
aTest.check(xChartDoc);
}
+void Chart2ExportTest::testAxisNumberFormatXLS()
+{
+ struct
+ {
+ void check( const Reference<chart2::XChartDocument>& xChartDoc, bool bNumFmtLinkedActual, sal_Int16 nNumFmtTypeFlag ) const
+ {
+ Reference<chart2::XAxis> xAxisY = getAxisFromDoc( xChartDoc, 0, 1, 0 );
+ bool bNumFmtLinked = false;
+ Reference<beans::XPropertySet> xPS( xAxisY, uno::UNO_QUERY_THROW );
+ xPS->getPropertyValue( "LinkNumberFormatToSource" ) >>= bNumFmtLinked;
+
+ if ( bNumFmtLinkedActual )
+ CPPUNIT_ASSERT_MESSAGE( "Y axis should have its number format linked to source.", bNumFmtLinked );
+ else
+ {
+ CPPUNIT_ASSERT_MESSAGE( "Y axis should not have its number format linked to source.", !bNumFmtLinked );
+
+ sal_Int32 nNumFmt = getNumberFormatFromAxis( xAxisY );
+ sal_Int16 nType = getNumberFormatType( xChartDoc, nNumFmt );
+ if ( nNumFmtTypeFlag == util::NumberFormat::PERCENT )
+ CPPUNIT_ASSERT_MESSAGE( "Y axis should be percentage format.", ( nType & util::NumberFormat::PERCENT ) );
+ else
+ CPPUNIT_ASSERT_MESSAGE( "Y axis should be number format.", ( nType & util::NumberFormat::NUMBER ) );
+ }
+ }
+
+ void change( const Reference<chart2::XChartDocument>& xChartDoc, bool bSetNumFmtLinked, sal_Int16 nNumFmtTypeFlag )
+ {
+ Reference<chart2::XAxis> xAxisY = getAxisFromDoc( xChartDoc, 0, 1, 0 );
+ Reference<beans::XPropertySet> xPS( xAxisY, uno::UNO_QUERY_THROW );
+ Any aAny( bSetNumFmtLinked );
+ xPS->setPropertyValue( "LinkNumberFormatToSource", aAny );
+ if ( !bSetNumFmtLinked )
+ {
+ Reference<util::XNumberFormatsSupplier> xNFS( xChartDoc, uno::UNO_QUERY_THROW );
+ Reference<util::XNumberFormats> xNumberFormats = xNFS->getNumberFormats();
+ CPPUNIT_ASSERT( xNumberFormats.is() );
+ lang::Locale aLocale{ "en", "US", "" };
+ Sequence<sal_Int32> aNumFmts = xNumberFormats->queryKeys( nNumFmtTypeFlag, aLocale, false );
+ CPPUNIT_ASSERT( aNumFmts.hasElements() );
+ aAny <<= aNumFmts[0];
+ xPS->setPropertyValue( CHART_UNONAME_NUMFMT, aAny );
+ }
+ }
+
+ } aTest;
+
+ load( "/chart2/qa/extras/data/xls/", "axis_sourceformatting.xls" );
+
+ Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet( 0, mxComponent );
+ aTest.check( xChartDoc, true, util::NumberFormat::PERCENT );
+
+ aTest.change( xChartDoc, false, util::NumberFormat::NUMBER );
+ // Write the document(xls) with changes made close it, load it and check if changes are intact
+ reload( "MS Excel 97" );
+ xChartDoc = getChartDocFromSheet( 0, mxComponent );
+ aTest.check( xChartDoc, false, util::NumberFormat::NUMBER );
+}
+
void Chart2ExportTest::testDataLabelBordersDOCX()
{
struct Check
diff --git a/chart2/qa/extras/data/xls/axis_sourceformatting.xls b/chart2/qa/extras/data/xls/axis_sourceformatting.xls
new file mode 100644
index 000000000000..2ee38b720857
--- /dev/null
+++ b/chart2/qa/extras/data/xls/axis_sourceformatting.xls
Binary files differ