summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-11-27 22:57:55 +0100
committerEike Rathke <erack@redhat.com>2015-11-28 00:29:41 +0100
commitc06b24dc5636e1924ece928aef25baa4fa03d30e (patch)
treed8e45b40ad726bd4d2507a43786f1505c9c27904 /oox
parent34d043b214fa97ab828e68e5d324d493485cbe9b (diff)
Resolves: tdf#96072 export Chart format codes in Excel notation
As for the change in chart2/qa/extras/chart2export.cxx Chart2ExportTest::testAxisNumberFormatXLSX() unit test: also Excel writes string parts of format codes quoted, including minus sign in negative subformat. Change-Id: I201bb012df818129cbc65de0eee8eca59e57d829 (cherry picked from commit 509cfa40691cf544519872a63335cff4a4d94006)
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/chartexport.cxx29
1 files changed, 21 insertions, 8 deletions
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 14e49a86161d..e62ad953442f 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -90,6 +90,10 @@
#include <comphelper/sequence.hxx>
#include <xmloff/SchXMLSeriesHelper.hxx>
#include "ColorPropertySet.hxx"
+
+#include <svl/zforlist.hxx>
+#include <svl/numuno.hxx>
+
#include <set>
#include <unordered_set>
@@ -3753,17 +3757,26 @@ bool ChartExport::isDeep3dChart()
OUString ChartExport::getNumberFormatCode(sal_Int32 nKey) const
{
+ /* XXX if this was called more than one or two times per export the two
+ * SvNumberFormatter instances and NfKeywordTable should be member
+ * variables and initialized only once. */
+
+ OUString aCode("General"); // init with fallback
uno::Reference<util::XNumberFormatsSupplier> xNumberFormatsSupplier(mxChartModel, uno::UNO_QUERY_THROW);
- uno::Reference<util::XNumberFormats> xNumberFormats = xNumberFormatsSupplier->getNumberFormats();
- uno::Reference<beans::XPropertySet> xNumberFormat = xNumberFormats->getByKey(nKey);
+ SvNumberFormatsSupplierObj* pSupplierObj = SvNumberFormatsSupplierObj::getImplementation( xNumberFormatsSupplier);
+ if (!pSupplierObj)
+ return aCode;
+
+ SvNumberFormatter* pNumberFormatter = pSupplierObj->GetNumberFormatter();
+ if (!pNumberFormatter)
+ return aCode;
- if (!xNumberFormat.is())
- return OUString();
+ SvNumberFormatter aTempFormatter( comphelper::getProcessComponentContext(), LANGUAGE_ENGLISH_US);
+ NfKeywordTable aKeywords;
+ aTempFormatter.FillKeywordTableForExcel( aKeywords);
+ aCode = pNumberFormatter->GetFormatStringForExcel( nKey, aKeywords, aTempFormatter);
- uno::Any aAny = xNumberFormat->getPropertyValue("FormatString");
- OUString aValue;
- aAny >>= aValue;
- return aValue;
+ return aCode;
}
}// drawingml