diff options
author | Justin Luth <justin.luth@collabora.com> | 2024-01-05 21:20:02 -0500 |
---|---|---|
committer | Justin Luth <jluth@mail.com> | 2024-01-09 21:33:38 +0100 |
commit | 0dd3df9400cebeb7cf24887a8640d07a3f9eb4b2 (patch) | |
tree | 92be33ecb1faa2b5357067829f235d295bcd23d2 /oox/source/drawingml/chart | |
parent | 2bafeb5835d1c11b3e217c0de3f9f430824079de (diff) |
tdf#137691 chart2 import: provide NumberFormat to DataSeries
make CppunitTest_chart2_export3 CPPUNIT_TEST_NAME=tdf137691
This patch provides some very foundational support
to importing a chart. It will open up a lot of doors
to improve LinkToSource - since now the Source key is defined.
Likely the source key should default to -1 instead of 0,
so that LinkToSource can know whether or not the source is defined.
/chart2/qa/extras/data/docx/testSeriesIdxOrder.docx
is an example of where this patchset SHOULD have worked,
but somehow it is losing its key during import...
Unfortunately I have run out of time and can not follow
these rabbit trails. Well, at least not until this change
is considered a regression for some particular document...
Change-Id: Ieddf2103002616aca2a408bde1f86d45c08dfc85
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161702
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'oox/source/drawingml/chart')
-rw-r--r-- | oox/source/drawingml/chart/datasourceconverter.cxx | 5 | ||||
-rw-r--r-- | oox/source/drawingml/chart/objectformatter.cxx | 22 |
2 files changed, 27 insertions, 0 deletions
diff --git a/oox/source/drawingml/chart/datasourceconverter.cxx b/oox/source/drawingml/chart/datasourceconverter.cxx index 92cacb4286bf..c07ea397d537 100644 --- a/oox/source/drawingml/chart/datasourceconverter.cxx +++ b/oox/source/drawingml/chart/datasourceconverter.cxx @@ -78,6 +78,11 @@ Reference< XDataSequence > DataSequenceConverter::createDataSequence( const OUSt // set sequence role PropertySet aSeqProp( xDataSeq ); aSeqProp.setProperty( PROP_Role, rRole ); + + const sal_Int32 nKey = getFormatter().getNumberFormatKey(mrModel.maFormatCode); + if (nKey >= 0) + aSeqProp.setProperty(PROP_NumberFormatKey, nKey); + return xDataSeq; } diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index ff52053c97c9..2013ea461753 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <com/sun/star/util/XNumberFormatTypes.hpp> +#include <comphelper/diagnose_ex.hxx> #include <osl/thread.h> #include <osl/diagnose.h> #include <rtl/strbuf.hxx> @@ -1149,6 +1150,27 @@ bool ObjectFormatter::isAutomaticFill( const ModelRef< Shape >& rxShapeProp ) return !rxShapeProp || !rxShapeProp->getFillProperties().moFillType.has_value(); } +sal_Int32 ObjectFormatter::getNumberFormatKey(const OUString& sNumberFormat) +{ + if (!mxData->mxNumFmts.is() || sNumberFormat.isEmpty()) + return -1; + + sal_Int32 nIndex = -1; + try + { + const bool bGeneral = sNumberFormat.equalsIgnoreAsciiCase("general"); + nIndex = bGeneral ? mxData->mxNumTypes->getStandardIndex(mxData->maFromLocale) + : mxData->mxNumFmts->addNewConverted(sNumberFormat, mxData->maEnUsLocale, + mxData->maFromLocale); + } + catch (Exception&) + { + DBG_UNHANDLED_EXCEPTION("oox.drawingml"); + } + + return nIndex; +} + } // namespace oox /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |