diff options
author | Kurt Zenker <kz@openoffice.org> | 2009-06-04 09:41:18 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2009-06-04 09:41:18 +0000 |
commit | a3acf41195f4c39cba7950c389dc817b824f76ed (patch) | |
tree | 18166c83c4ed3fe7d971b9e17f5bce1e0f031df2 /sc/source/filter/excel/xichart.cxx | |
parent | ce3275ad4a2c96c8178b3764c05085f9c8ad1265 (diff) |
CWS-TOOLING: integrate CWS chart37
2009-05-22 09:10:36 +0200 iha r272170 : #i102130# color of pies is not loaded correctly
2009-04-27 17:16:20 +0200 iha r271294 : #i24203# compiler problem
2009-04-27 16:43:21 +0200 iha r271292 : #i101281# missing API documentation for secondary axis title properties
2009-04-27 15:26:05 +0200 hde r271276 : #i100987
2009-04-27 15:24:42 +0200 hde r271273 : #i100987
2009-04-24 15:08:33 +0200 iha r271214 : #i100995# crash with some logarithmic scalings
2009-04-22 18:50:56 +0200 dr r271134 : #i82177# write out deleted point labels
2009-04-22 18:40:48 +0200 iha r271133 : #i101281# missing API documentation for secondary axis title properties
2009-04-22 16:39:42 +0200 dr r271128 : #i82177# extensions for bubble charts
2009-04-22 14:37:00 +0200 dr r271114 : #i82177# import/export data label type and separator
2009-04-22 14:36:24 +0200 dr r271113 : #i82177# import/export data label type and separator
2009-04-21 15:25:26 +0200 dr r271038 : #i82177# import data label type and separator from BIFF8 CHFR records
2009-04-21 14:37:16 +0200 dr r271037 : #i82177# dump BIFF8 chart future records
2009-04-20 17:44:27 +0200 iha r271002 : #i96898# reduce library exports
2009-04-20 13:01:13 +0200 iha r270975 : #i24203# rotate data labels - help ids
2009-04-20 11:40:33 +0200 dr r270969 : #i96600# export of axis scaling/positioning properties
2009-04-16 16:02:31 +0200 dr r270892 : #i69599# keep Y axis left in 3d charts
2009-04-15 18:16:46 +0200 dr r270859 : #i69599# import of axis position settings
2009-04-15 18:16:01 +0200 dr r270858 : #i69599# correct handling of logarithmic crossing axes
2009-04-14 16:27:48 +0200 dr r270794 : #i96599# handle auto axis position on logarithmic axes
2009-04-09 19:59:51 +0200 dr r270722 : #i96599# import axis crossing settings, fix import of logarithmic scaling settings
2009-04-09 18:26:00 +0200 iha r270720 : #i96898# reduce library exports
2009-04-09 15:17:04 +0200 iha r270710 : #i96898# reduce library exports
2009-04-09 10:50:14 +0200 dr r270682 : #i24203# import/export of data label rotation, fixed some other broken stuff too
2009-04-08 16:54:54 +0200 dr r270657 : #i24203# import rotation for data point labels
2009-04-06 18:19:17 +0200 iha r270571 : #i100876# Axis scaling settings dialog wrong after API usage (anys different from double type)
2009-04-06 15:57:05 +0200 iha r270567 : #i100105# #i58585# leftover ->
2009-04-06 15:55:48 +0200 iha r270564 : #i58585# leftover ->
2009-04-02 16:41:07 +0200 iha r270422 : #i99721# remove unused code
2009-04-02 14:29:03 +0200 iha r270407 : #i99721# remove unused code
2009-03-26 10:58:23 +0100 iha r270059 : #i96898# reduce library exports
2009-03-26 10:13:49 +0100 iha r270055 : #i96898# reduce library exports
2009-03-25 09:39:13 +0100 iha r269998 : CWS-TOOLING: rebase CWS chart37 to trunk@269781 (milestone: DEV300:m44)
2009-03-24 17:56:56 +0100 iha r269986 : #i96898# reduce library exports
2009-03-24 16:56:44 +0100 iha r269974 : #i99721# remove unused code
2009-03-24 16:48:48 +0100 iha r269970 : #i89731# remove unused string
2009-03-24 15:44:04 +0100 iha r269961 : remove unused code
2009-03-24 15:22:45 +0100 iha r269959 : remove unused code
2009-03-24 15:17:17 +0100 iha r269957 : remove unused code
2009-03-24 11:14:53 +0100 iha r269923 : #i24203# rotate data labels
2009-03-09 12:10:25 +0100 hde r269076 : #i99300#
2009-03-06 15:56:26 +0100 iha r269011 : #i93953# Source Format for secondary axis without data
2009-02-17 15:59:05 +0100 iha r268177 : avoid warning during build
2009-02-17 15:01:59 +0100 iha r268173 : avoid warning during build
2009-02-13 09:39:03 +0100 ufi r267693 : i96999
2009-02-11 15:12:35 +0100 iha r267604 : removed unused string
2009-02-11 14:00:29 +0100 iha r267600 : #i96999# Corrected wording from 'correlation coefficient' to 'coefficient of determination'
2009-02-11 10:56:45 +0100 iha r267584 : #i89731# typo in resource string
2009-02-11 10:01:29 +0100 iha r267582 : #i89031# compile error on asian windows systems
2009-02-10 16:15:16 +0100 iha r267552 : #i24203# rotate data labels
2009-02-04 18:00:33 +0100 iha r267395 : #i98893# don't export defaults to file
2009-02-04 15:48:15 +0100 iha r267390 : #i92128# asian typography for chart elements
2009-02-04 15:17:41 +0100 iha r267386 : #i92128# asian typography for chart elements
2009-01-30 14:41:10 +0100 iha r267197 : CWS-TOOLING: rebase CWS chart37 to trunk@267171 (milestone: DEV300:m41)
Diffstat (limited to 'sc/source/filter/excel/xichart.cxx')
-rw-r--r-- | sc/source/filter/excel/xichart.cxx | 267 |
1 files changed, 179 insertions, 88 deletions
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx index 14bc1c9c8cc9..d74071f17cab 100644 --- a/sc/source/filter/excel/xichart.cxx +++ b/sc/source/filter/excel/xichart.cxx @@ -39,6 +39,9 @@ #include <com/sun/star/drawing/Direction3D.hpp> #include <com/sun/star/drawing/ProjectionMode.hpp> #include <com/sun/star/drawing/ShadeMode.hpp> +#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp> +#include <com/sun/star/chart/ChartAxisLabelPosition.hpp> +#include <com/sun/star/chart/ChartAxisMarkPosition.hpp> #include <com/sun/star/chart/ChartAxisPosition.hpp> #include <com/sun/star/chart/XChartDocument.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> @@ -138,10 +141,10 @@ void lclSetValueOrClearAny( Any& rAny, const Type& rValue, bool bClear ) rAny <<= rValue; } -void lclSetScaledValueOrClearAny( Any& rAny, double fValue, Reference< XScaling > xScaling, bool bClear ) +void lclSetExpValueOrClearAny( Any& rAny, double fValue, bool bLogScale, bool bClear ) { - if( !bClear && xScaling.is() ) - fValue = xScaling->doScaling( fValue ); + if( !bClear && bLogScale ) + fValue = pow( 10.0, fValue ); lclSetValueOrClearAny( rAny, fValue, bClear ); } @@ -721,18 +724,14 @@ sal_uInt16 XclImpChSourceLink::GetCellCount() const void XclImpChSourceLink::ConvertNumFmt( ScfPropertySet& rPropSet, bool bPercent ) const { - if( ::get_flag( maData.mnFlags, EXC_CHSRCLINK_NUMFMT ) ) - { - sal_uInt32 nScNumFmt = GetNumFmtBuffer().GetScFormat( maData.mnNumFmtIdx ); - if( nScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND ) - { - sal_Int32 nApiNumFmt = static_cast< sal_Int32 >( nScNumFmt ); - if( bPercent ) - rPropSet.SetProperty( EXC_CHPROP_PERCENTAGENUMFMT, nApiNumFmt ); - else - rPropSet.SetProperty( EXC_CHPROP_NUMBERFORMAT, nApiNumFmt ); - } - } + bool bLinkToSource = ::get_flag( maData.mnFlags, EXC_CHSRCLINK_NUMFMT ); + sal_uInt32 nScNumFmt = bLinkToSource ? GetNumFmtBuffer().GetScFormat( maData.mnNumFmtIdx ) : NUMBERFORMAT_ENTRY_NOT_FOUND; + OUString aPropName = bPercent ? EXC_CHPROP_PERCENTAGENUMFMT : EXC_CHPROP_NUMBERFORMAT; + if( nScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND ) + rPropSet.SetProperty( aPropName, static_cast< sal_Int32 >( nScNumFmt ) ); + else + // restore 'link to source' at data point (series may contain manual number format) + rPropSet.SetAnyProperty( aPropName, Any() ); } Reference< XDataSequence > XclImpChSourceLink::CreateDataSequence( const OUString& rRole ) const @@ -752,7 +751,7 @@ Reference< XDataSequence > XclImpChSourceLink::CreateDataSequence( const OUStrin } else { - DBG_ERRORFILE( "XclImpChSourceLink::CreateDataSequence - cannot create data sequence" ); +// DBG_ERRORFILE( "XclImpChSourceLink::CreateDataSequence - cannot create data sequence" ); } // set sequence role @@ -806,9 +805,9 @@ void XclImpChFontBase::ConvertFontBase( const XclImpChRoot& rRoot, ScfPropertySe rRoot.ConvertFont( rPropSet, GetFontIndex(), &aFontColor ); } -void XclImpChFontBase::ConvertRotationBase( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet ) const +void XclImpChFontBase::ConvertRotationBase( const XclImpChRoot& rRoot, ScfPropertySet& rPropSet, bool bSupportsStacked ) const { - rRoot.GetChartPropSetHelper().WriteRotationProperties( rPropSet, GetRotation() ); + rRoot.GetChartPropSetHelper().WriteRotationProperties( rPropSet, GetRotation(), bSupportsStacked ); } // ---------------------------------------------------------------------------- @@ -879,6 +878,9 @@ void XclImpChText::ReadSubRecord( XclImpStream& rStrm ) case EXC_ID_CHOBJECTLINK: rStrm >> maObjLink.mnTarget >> maObjLink.maPointPos.mnSeriesIdx >> maObjLink.maPointPos.mnPointIdx; break; + case EXC_ID_CHFRLABELPROPS: + ReadChFrLabelProps( rStrm ); + break; case EXC_ID_CHEND: if( mxSrcLink.is() && !maFormats.empty() ) mxSrcLink->SetTextFormats( maFormats ); @@ -939,6 +941,11 @@ void XclImpChText::ConvertFont( ScfPropertySet& rPropSet ) const ConvertFontBase( GetChRoot(), rPropSet ); } +void XclImpChText::ConvertRotation( ScfPropertySet& rPropSet, bool bSupportsStacked ) const +{ + ConvertRotationBase( GetChRoot(), rPropSet, bSupportsStacked ); +} + void XclImpChText::ConvertFrame( ScfPropertySet& rPropSet ) const { if( mxFrame.is() ) @@ -953,27 +960,42 @@ void XclImpChText::ConvertNumFmt( ScfPropertySet& rPropSet, bool bPercent ) cons void XclImpChText::ConvertDataLabel( ScfPropertySet& rPropSet, const XclChTypeInfo& rTypeInfo ) const { - const sal_uInt16 EXC_CHTEXT_SHOWANYCATEG = EXC_CHTEXT_SHOWCATEGPERC | EXC_CHTEXT_SHOWCATEG; - const sal_uInt16 EXC_CHTEXT_SHOWANYVALUE = EXC_CHTEXT_SHOWVALUE; - const sal_uInt16 EXC_CHTEXT_SHOWANYPERCENT = EXC_CHTEXT_SHOWPERCENT | EXC_CHTEXT_SHOWCATEGPERC; + // existing CHFRLABELPROPS record wins over flags from CHTEXT + sal_uInt16 nShowFlags = mxLabelProps.is() ? mxLabelProps->mnFlags : maData.mnFlags; + sal_uInt16 SHOWANYCATEG = mxLabelProps.is() ? EXC_CHFRLABELPROPS_SHOWCATEG : (EXC_CHTEXT_SHOWCATEGPERC | EXC_CHTEXT_SHOWCATEG); + sal_uInt16 SHOWANYVALUE = mxLabelProps.is() ? EXC_CHFRLABELPROPS_SHOWVALUE : EXC_CHTEXT_SHOWVALUE; + sal_uInt16 SHOWANYPERCENT = mxLabelProps.is() ? EXC_CHFRLABELPROPS_SHOWPERCENT : (EXC_CHTEXT_SHOWPERCENT | EXC_CHTEXT_SHOWCATEGPERC); + sal_uInt16 SHOWANYBUBBLE = mxLabelProps.is() ? EXC_CHFRLABELPROPS_SHOWBUBBLE : EXC_CHTEXT_SHOWBUBBLE; - bool bIsPie = rTypeInfo.meTypeCateg == EXC_CHTYPECATEG_PIE; + // get raw flags for label values bool bShowNone = IsDeleted(); - bool bShowCateg = !bShowNone && ::get_flag( maData.mnFlags, EXC_CHTEXT_SHOWANYCATEG ); - bool bShowPercent = !bShowNone && bIsPie && ::get_flag( maData.mnFlags, EXC_CHTEXT_SHOWANYPERCENT ); - bool bShowValue = !bShowNone && !bShowPercent && ::get_flag( maData.mnFlags, EXC_CHTEXT_SHOWANYVALUE ); - bool bShowAny = bShowValue || bShowPercent || bShowCateg; - bool bShowSymbol = bShowAny && ::get_flag( maData.mnFlags, EXC_CHTEXT_SHOWSYMBOL ); + bool bShowCateg = !bShowNone && ::get_flag( nShowFlags, SHOWANYCATEG ); + bool bShowPercent = !bShowNone && ::get_flag( nShowFlags, SHOWANYPERCENT ); + bool bShowValue = !bShowNone && ::get_flag( nShowFlags, SHOWANYVALUE ); + bool bShowBubble = !bShowNone && ::get_flag( nShowFlags, SHOWANYBUBBLE ); + + // adjust to Chart2 behaviour + if( rTypeInfo.meTypeId == EXC_CHTYPEID_BUBBLES ) + bShowValue = bShowBubble; // Chart2 bubble charts show bubble size if 'ShowValue' is set - // type of attached label + // other flags + bool bShowAny = bShowValue || bShowPercent || bShowCateg; + bool bShowSymbol = bShowAny && ::get_flag( maData.mnFlags, EXC_CHTEXT_SHOWSYMBOL ); + + // create API struct for label values, set API label separator namespace cssc = ::com::sun::star::chart2; cssc::DataPointLabel aPointLabel( bShowValue, bShowPercent, bShowCateg, bShowSymbol ); rPropSet.SetProperty( EXC_CHPROP_LABEL, aPointLabel ); + String aSep = mxLabelProps.is() ? mxLabelProps->maSeparator : String( sal_Unicode( '\n' ) ); + if( aSep.Len() == 0 ) + aSep = CREATE_STRING( "; " ); + rPropSet.SetStringProperty( EXC_CHPROP_LABELSEPARATOR, aSep ); // text properties of attached label if( bShowAny ) { ConvertFont( rPropSet ); + ConvertRotation( rPropSet, false ); // label placement using namespace ::com::sun::star::chart::DataLabelPlacement; sal_Int32 nPlacement = rTypeInfo.mnDefaultLabelPos; @@ -1016,13 +1038,26 @@ Reference< XTitle > XclImpChText::CreateTitle() const // more title formatting properties ScfPropertySet aTitleProp( xTitle ); ConvertFrame( aTitleProp ); - ConvertRotationBase( GetChRoot(), aTitleProp ); + ConvertRotation( aTitleProp, true ); } } } return xTitle; } +void XclImpChText::ReadChFrLabelProps( XclImpStream& rStrm ) +{ + if( GetBiff() == EXC_BIFF8 ) + { + mxLabelProps.reset( new XclChFrLabelProps ); + sal_uInt16 nSepLen; + rStrm.Ignore( 12 ); + rStrm >> mxLabelProps->mnFlags >> nSepLen; + if( nSepLen > 0 ) + mxLabelProps->maSeparator = rStrm.ReadUniString( nSepLen ); + } +} + namespace { void lclUpdateText( XclImpChTextRef& rxText, XclImpChTextRef xDefText ) @@ -2593,25 +2628,38 @@ void XclImpChLabelRange::ReadChLabelRange( XclImpStream& rStrm ) void XclImpChLabelRange::Convert( ScfPropertySet& rPropSet, ScaleData& rScaleData, bool bMirrorOrient ) const { - namespace cssc = ::com::sun::star::chart2; - - // do not overlap text - rPropSet.SetBoolProperty( EXC_CHPROP_TEXTOVERLAP, false ); - // do not break text into several lines - rPropSet.SetBoolProperty( EXC_CHPROP_TEXTBREAK, false ); - - // origin (max-cross not supported, fall back to auto-cross) - bool bMaxCross = ::get_flag( maData.mnFlags, EXC_CHLABELRANGE_MAXCROSS ); - sal_uInt16 nCross = ::std::max< sal_uInt16 >( maData.mnCross, 1 ); - lclSetValueOrClearAny( rScaleData.Origin, static_cast< double >( nCross ), bMaxCross ); + // do not overlap text unless all labels are visible + rPropSet.SetBoolProperty( EXC_CHPROP_TEXTOVERLAP, maData.mnLabelFreq == 1 ); + // do not break text into several lines unless all labels are visible + rPropSet.SetBoolProperty( EXC_CHPROP_TEXTBREAK, maData.mnLabelFreq == 1 ); + // do not stagger labels in two lines + namespace cssc = ::com::sun::star::chart; + rPropSet.SetProperty( EXC_CHPROP_ARRANGEORDER, cssc::ChartAxisArrangeOrderType_SIDE_BY_SIDE ); // reverse order + namespace cssc2 = ::com::sun::star::chart2; bool bReverse = ::get_flag( maData.mnFlags, EXC_CHLABELRANGE_REVERSE ) != bMirrorOrient; - rScaleData.Orientation = bReverse ? cssc::AxisOrientation_REVERSE : cssc::AxisOrientation_MATHEMATICAL; + rScaleData.Orientation = bReverse ? cssc2::AxisOrientation_REVERSE : cssc2::AxisOrientation_MATHEMATICAL; //! TODO #i58731# show n-th category } +void XclImpChLabelRange::ConvertAxisPosition( ScfPropertySet& rPropSet, bool b3dChart ) const +{ + /* Crossing mode (max-cross flag overrides other crossing settings). Excel + does not move the Y axis in 3D charts, regardless of actual settings. + But: the Y axis has to be moved to "end", if the X axis is mirrored, + to keep it at the left end of the chart. */ + bool bMaxCross = ::get_flag( maData.mnFlags, b3dChart ? EXC_CHLABELRANGE_REVERSE : EXC_CHLABELRANGE_MAXCROSS ); + namespace cssc = ::com::sun::star::chart; + cssc::ChartAxisPosition eAxisPos = bMaxCross ? cssc::ChartAxisPosition_END : cssc::ChartAxisPosition_VALUE; + rPropSet.SetProperty( EXC_CHPROP_CROSSOVERPOSITION, eAxisPos ); + + // crossing position + double fCrossingPos = b3dChart ? 1.0 : maData.mnCross; + rPropSet.SetProperty( EXC_CHPROP_CROSSOVERVALUE, fCrossingPos ); +} + // ---------------------------------------------------------------------------- XclImpChValueRange::XclImpChValueRange( const XclImpChRoot& rRoot ) : @@ -2634,22 +2682,11 @@ void XclImpChValueRange::Convert( ScaleData& rScaleData, bool bMirrorOrient ) co // scaling algorithm bool bLogScale = ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_LOGSCALE ); OUString aScalingService = bLogScale ? SERVICE_CHART2_LOGSCALING : SERVICE_CHART2_LINEARSCALING; - Reference< XScaling > xScaling( ScfApiHelper::CreateInstance( aScalingService ), UNO_QUERY ); - Reference< XScaling > xLogScaling; - if( xScaling.is() ) - { - rScaleData.Scaling = xScaling; - if( bLogScale ) - xLogScaling = xScaling->getInverseScaling(); - } + rScaleData.Scaling.set( ScfApiHelper::CreateInstance( aScalingService ), UNO_QUERY ); // min/max - lclSetScaledValueOrClearAny( rScaleData.Minimum, maData.mfMin, xLogScaling, ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMIN ) ); - lclSetScaledValueOrClearAny( rScaleData.Maximum, maData.mfMax, xLogScaling, ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMAX ) ); - - // origin (max-cross overrides crossing settings, fall back to auto-cross) - const sal_uInt16 nAutoCrossFlags = EXC_CHVALUERANGE_AUTOCROSS | EXC_CHVALUERANGE_MAXCROSS; - lclSetScaledValueOrClearAny( rScaleData.Origin, maData.mfCross, xLogScaling, ::get_flag( maData.mnFlags, nAutoCrossFlags ) ); + lclSetExpValueOrClearAny( rScaleData.Minimum, maData.mfMin, bLogScale, ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMIN ) ); + lclSetExpValueOrClearAny( rScaleData.Maximum, maData.mfMax, bLogScale, ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMAX ) ); // increment bool bAutoMajor = ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOMAJOR ); @@ -2660,19 +2697,44 @@ void XclImpChValueRange::Convert( ScaleData& rScaleData, bool bMirrorOrient ) co // minor increment Sequence< SubIncrement >& rSubIncrementSeq = rIncrementData.SubIncrements; rSubIncrementSeq.realloc( 1 ); - sal_Int32 nCount = 0; - if( !bAutoMajor && !bAutoMinor && (0.0 < maData.mfMinorStep) && (maData.mfMinorStep <= maData.mfMajorStep) ) + Any& rIntervalCount = rSubIncrementSeq[ 0 ].IntervalCount; + if( bLogScale ) { - double fCount = maData.mfMajorStep / maData.mfMinorStep + 0.5; - if( fCount < 1001.0 ) - nCount = static_cast< sal_Int32 >( fCount ); + rIntervalCount <<= sal_Int32( 10 ); + } + else + { + sal_Int32 nCount = 0; + if( !bAutoMajor && !bAutoMinor && (0.0 < maData.mfMinorStep) && (maData.mfMinorStep <= maData.mfMajorStep) ) + { + double fCount = maData.mfMajorStep / maData.mfMinorStep + 0.5; + if( fCount < 1001.0 ) + nCount = static_cast< sal_Int32 >( fCount ); + } + lclSetValueOrClearAny( rIntervalCount, nCount, nCount == 0 ); } - lclSetValueOrClearAny( rSubIncrementSeq[ 0 ].IntervalCount, nCount, nCount == 0 ); // reverse order - namespace cssc = ::com::sun::star::chart2; + namespace cssc2 = ::com::sun::star::chart2; bool bReverse = ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_REVERSE ) != bMirrorOrient; - rScaleData.Orientation = bReverse ? cssc::AxisOrientation_REVERSE : cssc::AxisOrientation_MATHEMATICAL; + rScaleData.Orientation = bReverse ? cssc2::AxisOrientation_REVERSE : cssc2::AxisOrientation_MATHEMATICAL; +} + +void XclImpChValueRange::ConvertAxisPosition( ScfPropertySet& rPropSet ) const +{ + bool bMaxCross = ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_MAXCROSS ); + bool bAutoCross = ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_AUTOCROSS ); + bool bLogScale = ::get_flag( maData.mnFlags, EXC_CHVALUERANGE_LOGSCALE ); + + // crossing mode (max-cross flag overrides other crossing settings) + namespace cssc = ::com::sun::star::chart; + cssc::ChartAxisPosition eAxisPos = bMaxCross ? cssc::ChartAxisPosition_END : cssc::ChartAxisPosition_VALUE; + rPropSet.SetProperty( EXC_CHPROP_CROSSOVERPOSITION, eAxisPos ); + + // crossing position + double fCrossingPos = bAutoCross ? 0.0 : maData.mfCross; + if( bLogScale ) fCrossingPos = pow( 10.0, fCrossingPos ); + rPropSet.SetProperty( EXC_CHPROP_CROSSOVERVALUE, fCrossingPos ); } // ---------------------------------------------------------------------------- @@ -2688,6 +2750,18 @@ sal_Int32 lclGetApiTickmarks( sal_uInt8 nXclTickPos ) return nApiTickmarks; } +::com::sun::star::chart::ChartAxisLabelPosition lclGetApiLabelPosition( sal_Int8 nXclLabelPos ) +{ + using namespace ::com::sun::star::chart; + switch( nXclLabelPos ) + { + case EXC_CHTICK_LOW: return ChartAxisLabelPosition_OUTSIDE_START; + case EXC_CHTICK_HIGH: return ChartAxisLabelPosition_OUTSIDE_END; + case EXC_CHTICK_NEXT: return ChartAxisLabelPosition_NEAR_AXIS; + } + return ChartAxisLabelPosition_NEAR_AXIS; +} + } // namespace XclImpChTick::XclImpChTick( const XclImpChRoot& rRoot ) : @@ -2734,6 +2808,8 @@ void XclImpChTick::Convert( ScfPropertySet& rPropSet ) const { rPropSet.SetProperty( EXC_CHPROP_MAJORTICKS, lclGetApiTickmarks( maData.mnMajor ) ); rPropSet.SetProperty( EXC_CHPROP_MINORTICKS, lclGetApiTickmarks( maData.mnMinor ) ); + rPropSet.SetProperty( EXC_CHPROP_LABELPOSITION, lclGetApiLabelPosition( maData.mnLabelPos ) ); + rPropSet.SetProperty( EXC_CHPROP_MARKPOSITION, ::com::sun::star::chart::ChartAxisMarkPosition_AT_AXIS ); } // ---------------------------------------------------------------------------- @@ -2822,8 +2898,10 @@ sal_uInt16 XclImpChAxis::GetRotation() const return mxTick.is() ? mxTick->GetRotation() : EXC_CHART_AUTOROTATION; } -Reference< XAxis > XclImpChAxis::CreateAxis( const XclImpChTypeGroup& rTypeGroup, bool bPrimary ) const +Reference< XAxis > XclImpChAxis::CreateAxis( const XclImpChTypeGroup& rTypeGroup, const XclImpChAxis* pCrossingAxis ) const { + namespace cssc2 = ::com::sun::star::chart2; + // create the axis object (always) Reference< XAxis > xAxis( ScfApiHelper::CreateInstance( SERVICE_CHART2_AXIS ), UNO_QUERY ); if( xAxis.is() ) @@ -2853,7 +2931,7 @@ Reference< XAxis > XclImpChAxis::CreateAxis( const XclImpChTypeGroup& rTypeGroup else if( const XclImpChText* pDefText = GetChartData().GetDefaultText( EXC_CHTEXTTYPE_AXISLABEL ).get() ) pDefText->ConvertFont( aAxisProp ); // label text rotation - ConvertRotationBase( GetChRoot(), aAxisProp ); + ConvertRotationBase( GetChRoot(), aAxisProp, true ); // number format sal_uInt32 nScNumFmt = GetNumFmtBuffer().GetScFormat( mnNumFmtIdx ); if( nScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND ) @@ -2865,42 +2943,46 @@ Reference< XAxis > XclImpChAxis::CreateAxis( const XclImpChTypeGroup& rTypeGroup const XclChExtTypeInfo& rTypeInfo = rTypeGroup.GetTypeInfo(); ScaleData aScaleData = xAxis->getScaleData(); // set axis type - namespace ApiAxisType = ::com::sun::star::chart2::AxisType; switch( GetAxisType() ) { case EXC_CHAXIS_X: if( rTypeInfo.mbCategoryAxis ) { - aScaleData.AxisType = ApiAxisType::CATEGORY; + aScaleData.AxisType = cssc2::AxisType::CATEGORY; aScaleData.Categories = rTypeGroup.CreateCategSequence(); } else - aScaleData.AxisType = ApiAxisType::REALNUMBER; + aScaleData.AxisType = cssc2::AxisType::REALNUMBER; break; case EXC_CHAXIS_Y: aScaleData.AxisType = rTypeGroup.IsPercent() ? - ApiAxisType::PERCENT : ApiAxisType::REALNUMBER; + cssc2::AxisType::PERCENT : cssc2::AxisType::REALNUMBER; break; case EXC_CHAXIS_Z: - aScaleData.AxisType = ApiAxisType::SERIES; + aScaleData.AxisType = cssc2::AxisType::SERIES; break; } // axis scaling settings, dependent on axis type switch( aScaleData.AxisType ) { - case ApiAxisType::CATEGORY: - case ApiAxisType::SERIES: + case cssc2::AxisType::CATEGORY: + case cssc2::AxisType::SERIES: // #i71684# radar charts have reversed rotation direction mxLabelRange->Convert( aAxisProp, aScaleData, rTypeInfo.meTypeCateg == EXC_CHTYPECATEG_RADAR ); break; - case ApiAxisType::REALNUMBER: - case ApiAxisType::PERCENT: + case cssc2::AxisType::REALNUMBER: + case cssc2::AxisType::PERCENT: // #i85167# pie/donut charts have reversed rotation direction (at Y axis!) mxValueRange->Convert( aScaleData, rTypeInfo.meTypeCateg == EXC_CHTYPECATEG_PIE ); break; default: DBG_ERRORFILE( "XclImpChAxis::CreateAxis - unknown axis type" ); } + + /* Do not set a value to the Origin member anymore (will be done via + new axis properties 'CrossoverPosition' and 'CrossoverValue'). */ + aScaleData.Origin.clear(); + // write back xAxis->setScaleData( aScaleData ); @@ -2921,9 +3003,10 @@ Reference< XAxis > XclImpChAxis::CreateAxis( const XclImpChTypeGroup& rTypeGroup mxMinorGrid->Convert( GetChRoot(), aSubGridProp, EXC_CHOBJTYPE_GRIDLINE ); } - // axis position ------------------------------------------------------ + // position of crossing axis ------------------------------------------ - aAxisProp.SetProperty( CREATE_OUSTRING( "CrossoverPosition" ), bPrimary ? ::com::sun::star::chart::ChartAxisPosition_START : ::com::sun::star::chart::ChartAxisPosition_END ); + if( pCrossingAxis ) + pCrossingAxis->ConvertAxisPosition( aAxisProp, rTypeGroup ); } return xAxis; } @@ -2934,6 +3017,14 @@ void XclImpChAxis::ConvertWall( ScfPropertySet& rPropSet ) const mxWallFrame->Convert( rPropSet ); } +void XclImpChAxis::ConvertAxisPosition( ScfPropertySet& rPropSet, const XclImpChTypeGroup& rTypeGroup ) const +{ + if( ((GetAxisType() == EXC_CHAXIS_X) && rTypeGroup.GetTypeInfo().mbCategoryAxis) || (GetAxisType() == EXC_CHAXIS_Z) ) + mxLabelRange->ConvertAxisPosition( rPropSet, rTypeGroup.Is3dChart() ); + else + mxValueRange->ConvertAxisPosition( rPropSet ); +} + void XclImpChAxis::ReadChAxisLine( XclImpStream& rStrm ) { XclImpChLineFormatRef* pxLineFmt = 0; @@ -3041,13 +3132,13 @@ void XclImpChAxesSet::Finalize() // invalid chart type groups are deleted now, check again with IsValidAxesSet() if( IsValidAxesSet() ) { - // create dummy X axis for charts supporting category ranges - XclImpChTypeGroupRef xTypeGroup = GetFirstTypeGroup(); - if( !mxXAxis && xTypeGroup.is() && xTypeGroup->GetTypeInfo().mbCategoryAxis ) + // always create missing axis objects + if( !mxXAxis ) mxXAxis.reset( new XclImpChAxis( GetChRoot(), EXC_CHAXIS_X ) ); - // create dummy Y axis for pie/doughnut charts - if( !mxYAxis && xTypeGroup.is() && (xTypeGroup->GetTypeInfo().meTypeCateg == EXC_CHTYPECATEG_PIE) ) + if( !mxYAxis ) mxYAxis.reset( new XclImpChAxis( GetChRoot(), EXC_CHAXIS_Y ) ); + if( !mxZAxis && GetFirstTypeGroup()->Is3dDeepChart() ) + mxZAxis.reset( new XclImpChAxis( GetChRoot(), EXC_CHAXIS_Z ) ); // finalize axes if( mxXAxis.is() ) mxXAxis->Finalize(); @@ -3113,9 +3204,9 @@ void XclImpChAxesSet::Convert( Reference< XDiagram > xDiagram ) const } // create the axes with grids and axis titles and insert them into the diagram - ConvertAxis( mxXAxis, mxXAxisTitle, xCoordSystem ); - ConvertAxis( mxYAxis, mxYAxisTitle, xCoordSystem ); - ConvertAxis( mxZAxis, mxZAxisTitle, xCoordSystem ); + ConvertAxis( mxXAxis, mxXAxisTitle, xCoordSystem, mxYAxis.get() ); + ConvertAxis( mxYAxis, mxYAxisTitle, xCoordSystem, mxXAxis.get() ); + ConvertAxis( mxZAxis, mxZAxisTitle, xCoordSystem, 0 ); } } } @@ -3217,12 +3308,12 @@ Reference< XCoordinateSystem > XclImpChAxesSet::CreateCoordSystem( Reference< XD void XclImpChAxesSet::ConvertAxis( XclImpChAxisRef xChAxis, XclImpChTextRef xChAxisTitle, - Reference< XCoordinateSystem > xCoordSystem ) const + Reference< XCoordinateSystem > xCoordSystem, const XclImpChAxis* pCrossingAxis ) const { if( xChAxis.is() ) { // create and attach the axis object - Reference< XAxis > xAxis = CreateAxis( *xChAxis ); + Reference< XAxis > xAxis = CreateAxis( *xChAxis, pCrossingAxis ); if( xAxis.is() ) { // create and attach the axis title @@ -3248,11 +3339,11 @@ void XclImpChAxesSet::ConvertAxis( } } -Reference< XAxis > XclImpChAxesSet::CreateAxis( const XclImpChAxis& rChAxis ) const +Reference< XAxis > XclImpChAxesSet::CreateAxis( const XclImpChAxis& rChAxis, const XclImpChAxis* pCrossingAxis ) const { Reference< XAxis > xAxis; if( const XclImpChTypeGroup* pTypeGroup = GetFirstTypeGroup().get() ) - xAxis = rChAxis.CreateAxis( *pTypeGroup, GetAxesSetId() == EXC_CHAXESSET_PRIMARY ); + xAxis = rChAxis.CreateAxis( *pTypeGroup, pCrossingAxis ); return xAxis; } |