summaryrefslogtreecommitdiff
path: root/sc/source
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 /sc/source
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 'sc/source')
-rw-r--r--sc/source/filter/excel/xechart.cxx13
-rw-r--r--sc/source/filter/excel/xichart.cxx18
2 files changed, 19 insertions, 12 deletions
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