merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0020-cws-koheichart02-sc.diff
blob3631c84c170b8d0a4bc5b1e5f8b1979048821a99
1 diff --git sc/source/filter/excel/xechart.cxx sc/source/filter/excel/xechart.cxx
2 index cf80876..0155f7b 100644
3 --- sc/source/filter/excel/xechart.cxx
4 +++ sc/source/filter/excel/xechart.cxx
5 @@ -143,16 +143,27 @@ void lclWriteChFrBlockRecord( XclExpStream& rStrm, const XclChFrBlock& rFrBlock,
8 template< typename Type >
9 -inline bool lclIsAutoAnyOrGetValue( Type& rValue, const Any& rAny )
10 +inline bool lclIsAutoAnyOrGetValue( Type& rValue, const Any& rAny, bool bPercent )
12 - return !rAny.hasValue() || !(rAny >>= rValue);
13 + if (!rAny.hasValue())
14 + return true;
16 + if (rAny >>= rValue)
17 + {
18 + if (bPercent)
19 + rValue *= 100.0;
20 + return false;
21 + }
22 + else
23 + return true;
26 -bool lclIsAutoAnyOrGetScaledValue( double& rfValue, const Any& rAny, bool bLogScale )
27 +bool lclIsAutoAnyOrGetScaledValue( double& rfValue, const Any& rAny, bool bLogScale, bool bPercent )
29 - bool bIsAuto = lclIsAutoAnyOrGetValue( rfValue, rAny );
30 + bool bIsAuto = lclIsAutoAnyOrGetValue( rfValue, rAny, bPercent );
31 if( !bIsAuto && bLogScale )
32 rfValue = log( rfValue ) / log( 10.0 );
34 return bIsAuto;
37 @@ -2412,7 +2423,7 @@ void XclExpChLabelRange::Convert( const ScaleData& rScaleData, bool bMirrorOrien
39 // origin
40 double fOrigin = 0.0;
41 - if( !lclIsAutoAnyOrGetValue( fOrigin, rScaleData.Origin ) )
42 + if( !lclIsAutoAnyOrGetValue( fOrigin, rScaleData.Origin, false ) )
43 maData.mnCross = limit_cast< sal_uInt16 >( fOrigin, 1, 31999 );
45 // reverse order
46 @@ -2450,31 +2461,31 @@ XclExpChValueRange::XclExpChValueRange( const XclExpChRoot& rRoot ) :
50 -void XclExpChValueRange::Convert( const ScaleData& rScaleData )
51 +void XclExpChValueRange::Convert( const ScaleData& rScaleData, bool bPercent )
53 // scaling algorithm
54 bool bLogScale = ScfApiHelper::GetServiceName( rScaleData.Scaling ) == SERVICE_CHART2_LOGSCALING;
55 ::set_flag( maData.mnFlags, EXC_CHVALUERANGE_LOGSCALE, bLogScale );
57 // min/max
58 - bool bAutoMin = lclIsAutoAnyOrGetScaledValue( maData.mfMin, rScaleData.Minimum, bLogScale );
59 + bool bAutoMin = lclIsAutoAnyOrGetScaledValue( maData.mfMin, rScaleData.Minimum, bLogScale, bPercent );
60 ::set_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMIN, bAutoMin );
61 - bool bAutoMax = lclIsAutoAnyOrGetScaledValue( maData.mfMax, rScaleData.Maximum, bLogScale );
62 + bool bAutoMax = lclIsAutoAnyOrGetScaledValue( maData.mfMax, rScaleData.Maximum, bLogScale, bPercent );
63 ::set_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMAX, bAutoMax );
65 // origin
66 - bool bAutoCross = lclIsAutoAnyOrGetScaledValue( maData.mfCross, rScaleData.Origin, bLogScale );
67 + bool bAutoCross = lclIsAutoAnyOrGetScaledValue( maData.mfCross, rScaleData.Origin, bLogScale, bPercent );
68 ::set_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOCROSS, bAutoCross );
70 // major increment
71 const IncrementData& rIncrementData = rScaleData.IncrementData;
72 - bool bAutoMajor = lclIsAutoAnyOrGetValue( maData.mfMajorStep, rIncrementData.Distance ) || (maData.mfMajorStep <= 0.0);
73 + bool bAutoMajor = lclIsAutoAnyOrGetValue( maData.mfMajorStep, rIncrementData.Distance, bPercent ) || (maData.mfMajorStep <= 0.0);
74 ::set_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMAJOR, bAutoMajor );
75 // minor increment
76 const Sequence< SubIncrement >& rSubIncrementSeq = rIncrementData.SubIncrements;
77 sal_Int32 nCount = 0;
78 bool bAutoMinor = bLogScale || bAutoMajor || (rSubIncrementSeq.getLength() < 1) ||
79 - lclIsAutoAnyOrGetValue( nCount, rSubIncrementSeq[ 0 ].IntervalCount ) || (nCount < 1);
80 + lclIsAutoAnyOrGetValue( nCount, rSubIncrementSeq[ 0 ].IntervalCount, false ) || (nCount < 1);
81 if( !bAutoMinor )
82 maData.mfMinorStep = maData.mfMajorStep / nCount;
83 ::set_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMINOR, bAutoMinor );
84 @@ -2652,7 +2663,7 @@ void XclExpChAxis::SetRotation( sal_uInt16 nRotation )
85 mxTick->SetRotation( nRotation );
88 -void XclExpChAxis::Convert( Reference< XAxis > xAxis, Reference< XAxis > xCrossingAxis, const XclChExtTypeInfo& rTypeInfo )
89 +void XclExpChAxis::Convert( Reference< XAxis > xAxis, Reference< XAxis > xCrossingAxis, const XclChExtTypeInfo& rTypeInfo, bool bPercent )
91 ScfPropertySet aAxisProp( xAxis );
92 bool bCategoryAxis = ((GetAxisType() == EXC_CHAXIS_X) && rTypeInfo.mbCategoryAxis) || (GetAxisType() == EXC_CHAXIS_Z);
93 @@ -2682,7 +2693,7 @@ void XclExpChAxis::Convert( Reference< XAxis > xAxis, Reference< XAxis > xCrossi
95 mxValueRange.reset( new XclExpChValueRange( GetChRoot() ) );
96 if( xAxis.is() )
97 - mxValueRange->Convert( xAxis->getScaleData() );
98 + mxValueRange->Convert( xAxis->getScaleData(), bPercent );
99 // get position of crossing axis on this axis from passed axis object
100 if( aCrossingProp.Is() )
101 mxValueRange->ConvertAxisPosition( aCrossingProp );
102 @@ -2847,10 +2858,10 @@ sal_uInt16 XclExpChAxesSet::Convert( Reference< XDiagram > xDiagram, sal_uInt16
103 // create axes according to chart type (no axes for pie and donut charts)
104 if( rTypeInfo.meTypeCateg != EXC_CHTYPECATEG_PIE )
106 - ConvertAxis( mxXAxis, EXC_CHAXIS_X, mxXAxisTitle, EXC_CHOBJLINK_XAXIS, xCoordSystem, rTypeInfo, EXC_CHART_AXIS_Y );
107 - ConvertAxis( mxYAxis, EXC_CHAXIS_Y, mxYAxisTitle, EXC_CHOBJLINK_YAXIS, xCoordSystem, rTypeInfo, EXC_CHART_AXIS_X );
108 + ConvertAxis( mxXAxis, EXC_CHAXIS_X, mxXAxisTitle, EXC_CHOBJLINK_XAXIS, xCoordSystem, rTypeInfo, EXC_CHART_AXIS_Y, bPercent );
109 + ConvertAxis( mxYAxis, EXC_CHAXIS_Y, mxYAxisTitle, EXC_CHOBJLINK_YAXIS, xCoordSystem, rTypeInfo, EXC_CHART_AXIS_X, bPercent );
110 if( pGroup->Is3dDeepChart() )
111 - ConvertAxis( mxZAxis, EXC_CHAXIS_Z, mxZAxisTitle, EXC_CHOBJLINK_ZAXIS, xCoordSystem, rTypeInfo, EXC_CHART_AXIS_NONE );
112 + ConvertAxis( mxZAxis, EXC_CHAXIS_Z, mxZAxisTitle, EXC_CHOBJLINK_ZAXIS, xCoordSystem, rTypeInfo, EXC_CHART_AXIS_NONE, bPercent );
115 // X axis category ranges
116 @@ -2935,7 +2946,8 @@ void XclExpChAxesSet::ConvertAxis(
117 XclExpChAxisRef& rxChAxis, sal_uInt16 nAxisType,
118 XclExpChTextRef& rxChAxisTitle, sal_uInt16 nTitleTarget,
119 Reference< XCoordinateSystem > xCoordSystem, const XclChExtTypeInfo& rTypeInfo,
120 - sal_Int32 nCrossingAxisDim )
121 + sal_Int32 nCrossingAxisDim,
122 + bool bPercent )
124 // create and convert axis object
125 rxChAxis.reset( new XclExpChAxis( GetChRoot(), nAxisType ) );
126 @@ -2943,7 +2955,7 @@ void XclExpChAxesSet::ConvertAxis(
127 sal_Int32 nApiAxesSetIdx = GetApiAxesSetIndex();
128 Reference< XAxis > xAxis = lclGetApiAxis( xCoordSystem, nApiAxisDim, nApiAxesSetIdx );
129 Reference< XAxis > xCrossingAxis = lclGetApiAxis( xCoordSystem, nCrossingAxisDim, nApiAxesSetIdx );
130 - rxChAxis->Convert( xAxis, xCrossingAxis, rTypeInfo );
131 + rxChAxis->Convert( xAxis, xCrossingAxis, rTypeInfo, bPercent );
133 // create and convert axis title
134 Reference< XTitled > xTitled( xAxis, UNO_QUERY );
135 diff --git sc/source/filter/excel/xichart.cxx sc/source/filter/excel/xichart.cxx
136 index 41ec801..2c0af2d 100644
137 --- sc/source/filter/excel/xichart.cxx
138 +++ sc/source/filter/excel/xichart.cxx
139 @@ -2142,6 +2142,15 @@ Reference< XChartType > XclImpChType::CreateChartType( Reference< XDiagram > xDi
140 // additional properties
141 switch( maTypeInfo.meTypeCateg )
143 + case EXC_CHTYPECATEG_LINE:
145 + ScfPropertySet aTypeProp(xChartType);
146 + bool bStacked = (maData.mnFlags & EXC_CHLINE_STACKED);
147 + bool bPercent = (maData.mnFlags & EXC_CHLINE_PERCENT);
148 + aTypeProp.SetBoolProperty(EXC_CHPROP_STACKED, bStacked);
149 + aTypeProp.SetBoolProperty(EXC_CHPROP_PERCENT, bPercent);
151 + break;
152 case EXC_CHTYPECATEG_BAR:
154 ScfPropertySet aTypeProp( xChartType );
155 @@ -2150,6 +2159,10 @@ Reference< XChartType > XclImpChType::CreateChartType( Reference< XDiagram > xDi
156 aTypeProp.SetProperty( EXC_CHPROP_OVERLAPSEQ, aInt32Seq );
157 aInt32Seq[ 0 ] = aInt32Seq[ 1 ] = maData.mnGap;
158 aTypeProp.SetProperty( EXC_CHPROP_GAPWIDTHSEQ, aInt32Seq );
159 + bool bStacked = (maData.mnFlags & EXC_CHBAR_STACKED);
160 + bool bPercent = (maData.mnFlags & EXC_CHBAR_PERCENT);
161 + aTypeProp.SetBoolProperty(EXC_CHPROP_STACKED, bStacked);
162 + aTypeProp.SetBoolProperty(EXC_CHPROP_PERCENT, bPercent);
164 break;
165 case EXC_CHTYPECATEG_PIE:
166 @@ -2712,7 +2725,7 @@ void XclImpChValueRange::ReadChValueRange( XclImpStream& rStrm )
167 >> maData.mnFlags;
170 -void XclImpChValueRange::Convert( ScaleData& rScaleData, bool bMirrorOrient ) const
171 +void XclImpChValueRange::Convert( ScaleData& rScaleData, bool bMirrorOrient, bool bPercent ) const
173 // scaling algorithm
174 bool bLogScale = ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_LOGSCALE );
175 @@ -2720,15 +2733,18 @@ void XclImpChValueRange::Convert( ScaleData& rScaleData, bool bMirrorOrient ) co
176 rScaleData.Scaling.set( ScfApiHelper::CreateInstance( aScalingService ), UNO_QUERY );
178 // min/max
179 - lclSetExpValueOrClearAny( rScaleData.Minimum, maData.mfMin, bLogScale, ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMIN ) );
180 - lclSetExpValueOrClearAny( rScaleData.Maximum, maData.mfMax, bLogScale, ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMAX ) );
181 + double fMinVal = bPercent ? maData.mfMin/100.0 : maData.mfMin;
182 + double fMaxVal = bPercent ? maData.mfMax/100.0 : maData.mfMax;
183 + lclSetExpValueOrClearAny( rScaleData.Minimum, fMinVal, bLogScale, ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMIN ) );
184 + lclSetExpValueOrClearAny( rScaleData.Maximum, fMaxVal, bLogScale, ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMAX ) );
186 // increment
187 bool bAutoMajor = ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMAJOR );
188 bool bAutoMinor = ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMINOR );
189 // major increment
190 IncrementData& rIncrementData = rScaleData.IncrementData;
191 - lclSetValueOrClearAny( rIncrementData.Distance, maData.mfMajorStep, bAutoMajor );
192 + double fMajorStep = bPercent ? maData.mfMajorStep/100.0 : maData.mfMajorStep;
193 + lclSetValueOrClearAny( rIncrementData.Distance, fMajorStep, bAutoMajor );
194 // minor increment
195 Sequence< SubIncrement >& rSubIncrementSeq = rIncrementData.SubIncrements;
196 rSubIncrementSeq.realloc( 1 );
197 @@ -3007,8 +3023,11 @@ Reference< XAxis > XclImpChAxis::CreateAxis( const XclImpChTypeGroup& rTypeGroup
198 break;
199 case cssc2::AxisType::REALNUMBER:
200 case cssc2::AxisType::PERCENT:
202 + bool bPercent = (aScaleData.AxisType == cssc2::AxisType::PERCENT);
203 // #i85167# pie/donut charts have reversed rotation direction (at Y axis!)
204 - mxValueRange->Convert( aScaleData, rTypeInfo.meTypeCateg == EXC_CHTYPECATEG_PIE );
205 + mxValueRange->Convert( aScaleData, rTypeInfo.meTypeCateg == EXC_CHTYPECATEG_PIE, bPercent );
207 break;
208 default:
209 DBG_ERRORFILE( "XclImpChAxis::CreateAxis - unknown axis type" );
210 diff --git sc/source/filter/inc/xechart.hxx sc/source/filter/inc/xechart.hxx
211 index 8a724aa..6c04739 100644
212 --- sc/source/filter/inc/xechart.hxx
213 +++ sc/source/filter/inc/xechart.hxx
214 @@ -998,7 +998,7 @@ public:
215 explicit XclExpChValueRange( const XclExpChRoot& rRoot );
217 /** Converts value axis scaling settings. */
218 - void Convert( const ::com::sun::star::chart2::ScaleData& rScaleData );
219 + void Convert( const ::com::sun::star::chart2::ScaleData& rScaleData, bool bPercent );
220 /** Converts position settings of a crossing axis at this axis. */
221 void ConvertAxisPosition( const ScfPropertySet& rPropSet );
223 @@ -1058,7 +1058,7 @@ public:
224 virtual void SetRotation( sal_uInt16 nRotation );
226 /** Converts formatting and scaling settings from the passed axis. */
227 - void Convert( XAxisRef xAxis, XAxisRef xCrossingAxis, const XclChExtTypeInfo& rTypeInfo );
228 + void Convert( XAxisRef xAxis, XAxisRef xCrossingAxis, const XclChExtTypeInfo& rTypeInfo, bool bPercent );
229 /** Converts and writes 3D wall/floor properties from the passed diagram. */
230 void ConvertWall( XDiagramRef xDiagram );
232 @@ -1131,7 +1131,8 @@ private:
233 void ConvertAxis( XclExpChAxisRef& rxChAxis, sal_uInt16 nAxisType,
234 XclExpChTextRef& rxChAxisTitle, sal_uInt16 nTitleTarget,
235 XCoordSystemRef xCoordSystem, const XclChExtTypeInfo& rTypeInfo,
236 - sal_Int32 nCrossingAxisDim );
237 + sal_Int32 nCrossingAxisDim,
238 + bool bPercent );
240 virtual void WriteBody( XclExpStream& rStrm );
242 diff --git sc/source/filter/inc/xichart.hxx sc/source/filter/inc/xichart.hxx
243 index e923ee1..0686c26 100644
244 --- sc/source/filter/inc/xichart.hxx
245 +++ sc/source/filter/inc/xichart.hxx
246 @@ -1130,7 +1130,7 @@ public:
247 /** Reads the CHVALUERANGE record (numeric axis scaling properties). */
248 void ReadChValueRange( XclImpStream& rStrm );
249 /** Converts value axis scaling settings. */
250 - void Convert( ScaleData& rScaleData, bool bMirrorOrient ) const;
251 + void Convert( ScaleData& rScaleData, bool bMirrorOrient, bool bPercent ) const;
252 /** Converts position settings of this axis at a crossing axis. */
253 void ConvertAxisPosition( ScfPropertySet& rPropSet ) const;
255 diff --git sc/source/filter/inc/xlchart.hxx sc/source/filter/inc/xlchart.hxx
256 index 7e3873b..43ea79b 100644
257 --- sc/source/filter/inc/xlchart.hxx
258 +++ sc/source/filter/inc/xlchart.hxx
259 @@ -115,6 +115,7 @@ namespace com { namespace sun { namespace star {
260 #define EXC_CHPROP_OFFSET CREATE_OUSTRING( "Offset" )
261 #define EXC_CHPROP_OVERLAPSEQ CREATE_OUSTRING( "OverlapSequence" )
262 #define EXC_CHPROP_PERCENTAGENUMFMT CREATE_OUSTRING( "PercentageNumberFormat" )
263 +#define EXC_CHPROP_PERCENT CREATE_OUSTRING( "Percent" )
264 #define EXC_CHPROP_PERCENTDIAGONAL CREATE_OUSTRING( "PercentDiagonal" )
265 #define EXC_CHPROP_PERSPECTIVE CREATE_OUSTRING( "Perspective" )
266 #define EXC_CHPROP_POSITIVEERROR CREATE_OUSTRING( "PositiveError" )
267 @@ -129,6 +130,7 @@ namespace com { namespace sun { namespace star {
268 #define EXC_CHPROP_SHOWHIGHLOW CREATE_OUSTRING( "ShowHighLow" )
269 #define EXC_CHPROP_SHOWNEGATIVEERROR CREATE_OUSTRING( "ShowNegativeError" )
270 #define EXC_CHPROP_SHOWPOSITIVEERROR CREATE_OUSTRING( "ShowPositiveError" )
271 +#define EXC_CHPROP_STACKED CREATE_OUSTRING( "Stacked" )
272 #define EXC_CHPROP_STACKCHARACTERS CREATE_OUSTRING( "StackCharacters" )
273 #define EXC_CHPROP_STACKINGDIR CREATE_OUSTRING( "StackingDirection" )
274 #define EXC_CHPROP_STARTINGANGLE CREATE_OUSTRING( "StartingAngle" )