summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorBartosz Kosiorek <bartosz.kosiorek@tomtom.com>2018-02-07 02:57:30 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2018-04-07 11:39:01 +0200
commit40e722fd44e3cf026e1aee2b2c2c97eb57b53468 (patch)
tree26866e83beb66d9eb40f57cdef5c59bbd5b58dc1 /oox
parentdfd19459a336a6cd9a67a0d3dc3cf305de567be1 (diff)
tdf#114168 If minor axis unit is automatic, then set it to 5
Based on OOXML implementation in MS Excel, if Minor axis Unit is set to automatic, then during chart import, LibreOffice should set Interval Count to 5, to mimic behaviour of MS Excel. Becaues default Interval Count for LibreOffice is 2, we need to override it to 5. With that solution, the Minor axis unit is preserved also after saving to .ods file format. During .xlsx export, if Interval Count is set to 5, then treat is as automatic axis unit. Change-Id: Iab9209fb3950ef73e79229329606363b528d35fe Reviewed-on: https://gerrit.libreoffice.org/49327 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl> (cherry picked from commit 274825b4180c81540cd0d1b22c5243f1b39fe4db) Reviewed-on: https://gerrit.libreoffice.org/50676 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/chart/axisconverter.cxx7
-rw-r--r--oox/source/export/chartexport.cxx17
2 files changed, 20 insertions, 4 deletions
diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx
index 76f3585e04d2..40f770626777 100644
--- a/oox/source/drawingml/chart/axisconverter.cxx
+++ b/oox/source/drawingml/chart/axisconverter.cxx
@@ -273,7 +273,7 @@ void AxisConverter::convertFromModel(
case cssc2::AxisType::PERCENT:
{
// scaling algorithm
- bool bLogScale = lclIsLogarithmicScale( mrModel );
+ const bool bLogScale = lclIsLogarithmicScale( mrModel );
if( bLogScale )
aScaleData.Scaling = LogarithmicScaling::create( comphelper::getProcessComponentContext() );
else
@@ -303,6 +303,11 @@ void AxisConverter::convertFromModel(
if( (1.0 <= fCount) && (fCount < 1001.0) )
rIntervalCount <<= static_cast< sal_Int32 >( fCount );
}
+ else if( !mrModel.mofMinorUnit.has() )
+ {
+ // tdf#114168 If minor unit is not set then set interval to 5, as MS Excel do.
+ rIntervalCount <<= static_cast< sal_Int32 >( 5 );
+ }
}
break;
default:
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 657ae8ea98e2..86e7c7c6afb1 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2802,9 +2802,20 @@ void ChartExport::_exportAxis(
{
double dMinorUnit = 0;
mAny >>= dMinorUnit;
- pFS->singleElement( FSNS( XML_c, XML_minorUnit ),
- XML_val, IS( dMinorUnit ),
- FSEND );
+ if( GetProperty( xAxisProp, "StepHelpCount" ) )
+ {
+ sal_Int32 dMinorUnitCount = 0;
+ mAny >>= dMinorUnitCount;
+ // tdf#114168 Don't save minor unit if number of step help count is 5 (which is default for MS Excel),
+ // to allow proper .xlsx import. If minorUnit is set and majorUnit not, then it is impossible
+ // to calculate StepHelpCount.
+ if( dMinorUnitCount != 5 )
+ {
+ pFS->singleElement( FSNS( XML_c, XML_minorUnit ),
+ XML_val, IS( dMinorUnit ),
+ FSEND );
+ }
+ }
}
if( nAxisType == XML_valAx && GetProperty( xAxisProp, "DisplayUnits" ) )