diff options
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/drawingml/chart/objectformatter.hxx | 3 | ||||
-rw-r--r-- | oox/source/drawingml/chart/axisconverter.cxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/chart/chartconverter.cxx | 7 | ||||
-rw-r--r-- | oox/source/drawingml/chart/chartspaceconverter.cxx | 14 | ||||
-rw-r--r-- | oox/source/drawingml/chart/objectformatter.cxx | 24 | ||||
-rw-r--r-- | oox/source/drawingml/chart/seriesconverter.cxx | 2 |
6 files changed, 25 insertions, 27 deletions
diff --git a/oox/inc/drawingml/chart/objectformatter.hxx b/oox/inc/drawingml/chart/objectformatter.hxx index ebe5a01d8991..d3a6a6d1668c 100644 --- a/oox/inc/drawingml/chart/objectformatter.hxx +++ b/oox/inc/drawingml/chart/objectformatter.hxx @@ -131,7 +131,8 @@ public: void convertNumberFormat( PropertySet& rPropSet, const NumberFormat& rNumberFormat, - bool bPercentFormat = false ); + bool bAxis, + bool bShowPercent = false ); /** Sets automatic fill properties to the passed property set. */ void convertAutomaticFill( diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx index ed74ef5ef407..076789579f91 100644 --- a/oox/source/drawingml/chart/axisconverter.cxx +++ b/oox/source/drawingml/chart/axisconverter.cxx @@ -325,7 +325,7 @@ void AxisConverter::convertFromModel( // number format ------------------------------------------------------ if( (aScaleData.AxisType == cssc2::AxisType::REALNUMBER) || (aScaleData.AxisType == cssc2::AxisType::PERCENT) ) - getFormatter().convertNumberFormat(aAxisProp, mrModel.maNumberFormat, false); + getFormatter().convertNumberFormat(aAxisProp, mrModel.maNumberFormat, true); // position of crossing axis ------------------------------------------ diff --git a/oox/source/drawingml/chart/chartconverter.cxx b/oox/source/drawingml/chart/chartconverter.cxx index bfa9d5ca6fb4..7304fbc2dc0a 100644 --- a/oox/source/drawingml/chart/chartconverter.cxx +++ b/oox/source/drawingml/chart/chartconverter.cxx @@ -20,6 +20,8 @@ #include "oox/drawingml/chart/chartconverter.hxx" #include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/data/XDataReceiver.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include "drawingml/chart/chartspaceconverter.hxx" #include "drawingml/chart/chartspacemodel.hxx" #include "oox/helper/containerhelper.hxx" @@ -96,6 +98,11 @@ void ChartConverter::convertFromModel( XmlFilterBase& rFilter, OSL_ENSURE( rxChartDoc.is(), "ChartConverter::convertFromModel - missing chart document" ); if( rxChartDoc.is() ) { + Reference< data::XDataReceiver > xDataReceiver( rxChartDoc, uno::UNO_QUERY_THROW ); + Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( rFilter.getModel(), uno::UNO_QUERY ); + if (xNumberFormatsSupplier.is()) + xDataReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier ); + ConverterRoot aConvBase( rFilter, *this, rChartModel, rxChartDoc, rChartSize ); ChartSpaceConverter aSpaceConv( aConvBase, rChartModel ); aSpaceConv.convertFromModel( rxExternalPage, rChartPos ); diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx b/oox/source/drawingml/chart/chartspaceconverter.cxx index f29016caa80c..37de52d23832 100644 --- a/oox/source/drawingml/chart/chartspaceconverter.cxx +++ b/oox/source/drawingml/chart/chartspaceconverter.cxx @@ -23,7 +23,6 @@ #include <com/sun/star/chart/XChartDocument.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XTitled.hpp> -#include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/FillStyle.hpp> #include "oox/core/xmlfilterbase.hxx" @@ -40,12 +39,10 @@ using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::makeAny; -using ::com::sun::star::util::XNumberFormatsSupplier; using ::com::sun::star::drawing::XDrawPageSupplier; using ::com::sun::star::drawing::XShapes; using ::com::sun::star::chart2::XDiagram; using ::com::sun::star::chart2::XTitled; -using ::com::sun::star::chart2::data::XDataReceiver; using ::com::sun::star::beans::XPropertySet; namespace oox { @@ -77,17 +74,6 @@ void ChartSpaceConverter::convertFromModel( const Reference< XShapes >& rxExtern derived converters may create an external data provider) */ getChartConverter()->createDataProvider( getChartDocument() ); - // attach number formatter of container document to data receiver - try - { - Reference< XDataReceiver > xDataRec( getChartDocument(), UNO_QUERY_THROW ); - Reference< XNumberFormatsSupplier > xNumFmtSupp( getFilter().getModel(), UNO_QUERY_THROW ); - xDataRec->attachNumberFormatsSupplier( xNumFmtSupp ); - } - catch( Exception& ) - { - } - // formatting of the chart background. The default fill style varies with applications. PropertySet aBackPropSet( getChartDocument()->getPageBackground() ); aBackPropSet.setProperty( diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index 89fa237a85f8..abf5bcb78c20 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -1084,19 +1084,21 @@ void ObjectFormatter::convertTextRotation( PropertySet& rPropSet, const ModelRef } } -void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFormat& rNumberFormat, bool bPercentFormat ) +void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFormat& rNumberFormat, bool bAxis, bool bShowPercent ) { if( mxData->mxNumFmts.is() ) { - sal_Int32 nPropId = bPercentFormat ? PROP_PercentageNumberFormat : PROP_NumberFormat; + const bool bGeneral = rNumberFormat.maFormatCode.equalsIgnoreAsciiCase("general"); + const bool bPercent = !bAxis && bShowPercent && !rNumberFormat.mbSourceLinked; + sal_Int32 nPropId = bPercent ? PROP_PercentageNumberFormat : PROP_NumberFormat; + OUString sFormatCode(rNumberFormat.maFormatCode); + if (bPercent && bGeneral) + sFormatCode = OUString("0%"); try { - bool bGeneral = rNumberFormat.maFormatCode.equalsIgnoreAsciiCase("general"); - sal_Int32 nIndex = bGeneral && !bPercentFormat ? + sal_Int32 nIndex = bGeneral && !bPercent ? mxData->mxNumTypes->getStandardIndex( mxData->maFromLocale ) : - mxData->mxNumFmts->addNewConverted( - bGeneral ? OUString("0%") : rNumberFormat.maFormatCode, - mxData->maEnUsLocale, mxData->maFromLocale ); + mxData->mxNumFmts->addNewConverted( sFormatCode, mxData->maEnUsLocale, mxData->maFromLocale ); if( nIndex >= 0 ) rPropSet.setProperty( nPropId, nIndex ); } @@ -1106,9 +1108,11 @@ void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFo append( OUStringToOString( rNumberFormat.maFormatCode, osl_getThreadTextEncoding() ) ).append( '\'' ).getStr() ); } - // Format code is ignored if "LinkNumberFormatToSource" is set to "true" :-/ - // See AxisHelper::getExplicitNumberFormatKeyForAxis() - rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.maFormatCode.isEmpty())); + // Setting "LinkNumberFormatToSource" does not really work, at least not for axis :-/ + if (!bAxis) + rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.mbSourceLinked)); + else + rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.maFormatCode.isEmpty())); } } diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index b1b996096a43..ab4f7df381b8 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -132,7 +132,7 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt if( !rDataLabel.mbDeleted ) { // data label number format (percentage format wins over value format) - rFormatter.convertNumberFormat( rPropSet, rDataLabel.maNumberFormat, bShowPercent ); + rFormatter.convertNumberFormat( rPropSet, rDataLabel.maNumberFormat, false, bShowPercent ); // data label text formatting (frame formatting not supported by Chart2) rFormatter.convertTextFormatting( rPropSet, rDataLabel.mxTextProp, OBJECTTYPE_DATALABEL ); |