summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oox/source/drawingml/chart/axisconverter.cxx7
-rw-r--r--oox/source/export/chartexport.cxx17
-rw-r--r--sc/source/filter/excel/xechart.cxx13
-rw-r--r--sc/source/filter/excel/xichart.cxx18
4 files changed, 39 insertions, 16 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" ) )
diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx
index d45e694bb557..15e6f2e9441d 100644
--- a/sc/source/filter/excel/xechart.cxx
+++ b/sc/source/filter/excel/xechart.cxx
@@ -2748,14 +2748,19 @@ void XclExpChValueRange::Convert( const ScaleData& rScaleData )
// major increment
const IncrementData& rIncrementData = rScaleData.IncrementData;
- bool bAutoMajor = lclIsAutoAnyOrGetValue( maData.mfMajorStep, rIncrementData.Distance ) || (maData.mfMajorStep <= 0.0);
+ const bool bAutoMajor = lclIsAutoAnyOrGetValue( maData.mfMajorStep, rIncrementData.Distance ) || (maData.mfMajorStep <= 0.0);
::set_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMAJOR, bAutoMajor );
// minor increment
const Sequence< SubIncrement >& rSubIncrementSeq = rIncrementData.SubIncrements;
sal_Int32 nCount = 0;
- bool bAutoMinor = bLogScale || bAutoMajor || (rSubIncrementSeq.getLength() < 1) ||
- lclIsAutoAnyOrGetValue( nCount, rSubIncrementSeq[ 0 ].IntervalCount ) || (nCount < 1);
- if( !bAutoMinor )
+
+ // tdf#114168 If IntervalCount is 5, then enable automatic minor calculation.
+ // During import, if minorUnit is set and majorUnit not, then it is impossible
+ // to calculate IntervalCount.
+ const bool bAutoMinor = bLogScale || bAutoMajor || (rSubIncrementSeq.getLength() < 1) ||
+ lclIsAutoAnyOrGetValue( nCount, rSubIncrementSeq[ 0 ].IntervalCount ) || (nCount < 1) || (nCount == 5);
+
+ if( maData.mfMajorStep && !bAutoMinor )
maData.mfMinorStep = maData.mfMajorStep / nCount;
::set_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMINOR, bAutoMinor );
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 895a9caa5e7c..82e06201ad67 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -3071,7 +3071,7 @@ void XclImpChValueRange::ReadChValueRange( XclImpStream& rStrm )
void XclImpChValueRange::Convert( ScaleData& rScaleData, bool bMirrorOrient ) const
{
// scaling algorithm
- bool bLogScale = ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_LOGSCALE );
+ const bool bLogScale = ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_LOGSCALE );
if( bLogScale )
rScaleData.Scaling = css::chart2::LogarithmicScaling::create( comphelper::getProcessComponentContext() );
else
@@ -3097,14 +3097,16 @@ void XclImpChValueRange::Convert( ScaleData& rScaleData, bool bMirrorOrient ) co
if( !bAutoMinor )
rIntervalCount <<= sal_Int32( 9 );
}
- else
+ else if( !bAutoMajor && !bAutoMinor && (0.0 < maData.mfMinorStep) && (maData.mfMinorStep <= maData.mfMajorStep) )
{
- if( !bAutoMajor && !bAutoMinor && (0.0 < maData.mfMinorStep) && (maData.mfMinorStep <= maData.mfMajorStep) )
- {
- double fCount = maData.mfMajorStep / maData.mfMinorStep + 0.5;
- if( (1.0 <= fCount) && (fCount < 1001.0) )
- rIntervalCount <<= static_cast< sal_Int32 >( fCount );
- }
+ double fCount = maData.mfMajorStep / maData.mfMinorStep + 0.5;
+ if( (1.0 <= fCount) && (fCount < 1001.0) )
+ rIntervalCount <<= static_cast< sal_Int32 >( fCount );
+ }
+ else if( bAutoMinor )
+ {
+ // tdf#114168 If minor unit is not set then set interval to 5, as MS Excel do.
+ rIntervalCount <<= static_cast< sal_Int32 >( 5 );
}
// reverse order