[ooo-build-commit] .: patches/dev300

Pei Feng Lin pflin at kemper.freedesktop.org
Wed Jan 27 22:04:23 PST 2010


 patches/dev300/oox-chart-export-part1.diff |  682 ++++++++++++++++++++---------
 1 file changed, 479 insertions(+), 203 deletions(-)

New commits:
commit dd5da7624188e9d0dee62dc7499057933f184ec2
Author: Fong Lin <pflin at novell.com>
Date:   Thu Jan 28 13:59:39 2010 +0800

    more support for chart axes
    
    * patches/dev300/oox-chart-export-part1.diff:

diff --git a/patches/dev300/oox-chart-export-part1.diff b/patches/dev300/oox-chart-export-part1.diff
index 12e3c16..945c5a3 100644
--- a/patches/dev300/oox-chart-export-part1.diff
+++ b/patches/dev300/oox-chart-export-part1.diff
@@ -1,9 +1,9 @@
 diff --git oox/inc/oox/export/chartexport.hxx oox/inc/oox/export/chartexport.hxx
 new file mode 100644
-index 0000000..cb9438f
+index 0000000..1a5710e
 --- /dev/null
 +++ oox/inc/oox/export/chartexport.hxx
-@@ -0,0 +1,218 @@
+@@ -0,0 +1,233 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -174,6 +174,13 @@ index 0000000..cb9438f
 +    void exportSeries(
 +        com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > xDiagram,
 +        com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > xNewDiagram );
++    void exportCandleStickSeries(
++        const ::com::sun::star::uno::Sequence<
++            ::com::sun::star::uno::Reference<
++                ::com::sun::star::chart2::XDataSeries > > & aSeriesSeq,
++        const ::com::sun::star::uno::Reference<
++            ::com::sun::star::chart2::XDiagram > & xDiagram,
++        sal_Bool bJapaneseCandleSticks );
 +    void exportDataSeq(
 +        const com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xValueSeq,
 +        sal_Int32 elementTokenId );
@@ -182,7 +189,7 @@ index 0000000..cb9438f
 +    void exportSeriesCategory(
 +        const com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xValueSeq );
 +    void exportSeriesValues(
-+        const com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xValueSeq );
++        const com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_val );
 +    void exportShapeProps( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet );
 +    void exportDataPoints( 
 +        const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSeriesProperties,
@@ -198,7 +205,15 @@ index 0000000..cb9438f
 +    void exportYAxis(
 +        com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > xDiagram,
 +        com::sun::star::uno::Reference< com::sun::star::chart2::XDiagram > xNewDiagram );
-+    void exportGridLines( sal_Bool bHasMajorLine, sal_Bool bHasMinorLine );
++    void _exportAxis(
++        const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisProp,
++        const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xAxisTitle,
++        const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xMajorGrid,
++        const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xMinorGrid,
++        sal_Int32 nAxisType,
++        const char* sAxisPos,
++        sal_Int32 nAxisId,
++        sal_Int32 nCrossAx );
 +    void exportAxesId( );
 +
 +public:
@@ -1052,10 +1067,10 @@ index 0000000..6c8a458
 +#endif
 diff --git oox/source/export/chartexport.cxx oox/source/export/chartexport.cxx
 new file mode 100644
-index 0000000..c300972
+index 0000000..65a69e6
 --- /dev/null
 +++ oox/source/export/chartexport.cxx
-@@ -0,0 +1,2136 @@
+@@ -0,0 +1,2397 @@
 +/*************************************************************************
 + *
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -1107,6 +1122,9 @@ index 0000000..c300972
 +#include <com/sun/star/chart/XStatisticDisplay.hpp>
 +#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp>
 +#include <com/sun/star/chart/ChartSymbolType.hpp>
++#include <com/sun/star/chart/ChartAxisMarks.hpp>
++#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
++#include <com/sun/star/chart/ChartAxisPosition.hpp>
 +
 +#include <com/sun/star/chart2/XChartDocument.hpp>
 +#include <com/sun/star/chart2/XDiagram.hpp>
@@ -1690,11 +1708,9 @@ index 0000000..c300972
 +    if( xParser.is() )
 +    {
 +        OSL_TRACE("ChartExport::parseFormula, parser is valid");
-+        //OUString aRange = OUString::createFromAscii("$Sheet1.$A$1:$C$1");
 +        Reference< XPropertySet > xParserProps( xParser, uno::UNO_QUERY );
 +        if( xParserProps.is() )
 +        {
-+            OSL_TRACE("ChartExport::parseFormula, got the parser property");
 +            xParserProps->setPropertyValue( OUString::createFromAscii("FormulaConvention"), uno::makeAny(::com::sun::star::sheet::AddressConvention::OOO) );
 +        }
 +        uno::Sequence<sheet::FormulaToken> aTokens = xParser->parseFormula( rRange, CellAddress( 0, 0, 0 ) );
@@ -2354,8 +2370,8 @@ index 0000000..c300972
 +}
 +
 +void ChartExport::exportOfPieChart(
-+    Reference< ::com::sun::star::chart::XDiagram > xDiagram,
-+    Reference< chart2::XDiagram > xNewDiagram )
++    Reference< ::com::sun::star::chart::XDiagram > /*xDiagram*/,
++    Reference< chart2::XDiagram > /*xNewDiagram*/ )
 +{
 +    // TODO:
 +}
@@ -2427,6 +2443,48 @@ index 0000000..c300972
 +            FSEND );
 +
 +    exportSeries( xDiagram, xNewDiagram );
++    // export stock properties
++    Reference< ::com::sun::star::chart::XStatisticDisplay > xStockPropProvider( xDiagram, uno::UNO_QUERY );
++    if( xStockPropProvider.is())
++    {
++        // stock-range-line
++        Reference< beans::XPropertySet > xStockPropSet = xStockPropProvider->getMinMaxLine();
++        if( xStockPropSet.is() )
++        {
++            pFS->startElement( FSNS( XML_c, XML_hiLowLines ),
++                FSEND );
++            exportShapeProps( xStockPropSet );
++            pFS->endElement( FSNS( XML_c, XML_hiLowLines ) );
++        }
++        // stock updownbar
++        pFS->startElement( FSNS( XML_c, XML_upDownBars ),
++                FSEND );
++        // TODO: gapWidth        
++        sal_Int32 nGapWidth = 150;
++        pFS->singleElement( FSNS( XML_c, XML_gapWidth ),
++            XML_val, I32S( nGapWidth ),
++            FSEND );
++        
++        xStockPropSet = xStockPropProvider->getUpBar();
++        if( xStockPropSet.is() )
++        {
++            pFS->startElement( FSNS( XML_c, XML_upBars ),
++                FSEND );
++            exportShapeProps( xStockPropSet );
++            pFS->endElement( FSNS( XML_c, XML_upBars ) );
++        }
++
++        xStockPropSet = xStockPropProvider->getDownBar();
++        if( xStockPropSet.is() )
++        {
++            pFS->startElement( FSNS( XML_c, XML_downBars ),
++                FSEND );
++            exportShapeProps( xStockPropSet );
++            pFS->endElement( FSNS( XML_c, XML_downBars ) );
++        }
++        pFS->endElement( FSNS( XML_c, XML_upDownBars ) );
++    }
++
 +    exportAxesId();
 +
 +    pFS->endElement( FSNS( XML_c, XML_stockChart ) );
@@ -2482,6 +2540,18 @@ index 0000000..c300972
 +            OUString aChartType( aCTSeq[nCTIdx]->getChartType());
 +            OUString aLabelRole = aCTSeq[nCTIdx]->getRoleOfSequenceForSeriesLabel();
 +
++            // special export for stock charts
++            if( aChartType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType")))
++            {
++                sal_Bool bJapaneseCandleSticks = sal_False;
++                Reference< beans::XPropertySet > xCTProp( aCTSeq[nCTIdx], uno::UNO_QUERY );
++                if( xCTProp.is())
++                    xCTProp->getPropertyValue( OUString::createFromAscii("Japanese")) >>= bJapaneseCandleSticks;
++                exportCandleStickSeries(
++                    xDSCnt->getDataSeries(), xNewDiagram, bJapaneseCandleSticks );
++                continue;
++            }
++
 +            // export dataseries for current chart-type
 +            Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
 +            for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
@@ -2554,10 +2624,44 @@ index 0000000..c300972
 +                            // export categories
 +                            if( xCatSeq.is() )
 +                                exportSeriesCategory( xCatSeq );
++                            
++                            sal_Int32 eChartType = getChartType( xDiagram );
++                            if( (eChartType == chart::TYPEID_SCATTER)
++                                || (eChartType == chart::TYPEID_BUBBLE) )
++                            {
++                                // export xVal
++                                Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString::createFromAscii("values-x" ) ) );
++                                if( xSequence.is() )
++                                {
++                                    Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
++                                    if( xValues.is() )
++                                        exportSeriesValues( xValues, XML_xVal );
++                                }
++                            }
++
++
++                            if( eChartType == chart::TYPEID_BUBBLE )
++                            {
++                                // export yVal
++                                Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString::createFromAscii("values-y" ) ) );
++                                if( xSequence.is() )
++                                {
++                                    Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() );
++                                    if( xValues.is() )
++                                        exportSeriesValues( xValues, XML_yVal );
++                                }        
++                            }
 +
 +                            // export values
 +                            if( xValuesSeq.is() )
-+                                exportSeriesValues( xValuesSeq );
++                            {
++                                sal_Int32 nYValueType = XML_val;
++                                if( eChartType == chart::TYPEID_SCATTER )
++                                    nYValueType = XML_yVal;
++                                else if( eChartType == chart::TYPEID_BUBBLE )
++                                    nYValueType = XML_bubbleSize;
++                                exportSeriesValues( xValuesSeq, nYValueType );
++                            }    
 +
 +                            pFS->endElement( FSNS( XML_c, XML_ser ) );
 +                        }
@@ -2568,6 +2672,87 @@ index 0000000..c300972
 +    }    
 +}
 +
++void ChartExport::exportCandleStickSeries(
++    const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq,
++    const Reference< chart2::XDiagram > & xNewDiagram,
++    sal_Bool bJapaneseCandleSticks )
++{
++    // get categories range
++    Reference< chart2::data::XDataSequence > xCatSeq;
++    if( mbHasCategoryLabels && xNewDiagram.is())
++    {
++        Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xNewDiagram ) );
++        if( xCategories.is() )
++        {
++            xCatSeq.set( xCategories->getValues() );
++        }
++    }
++
++    for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
++    {
++        Reference< chart2::XDataSeries > xSeries( aSeriesSeq[nSeriesIdx] );
++        //sal_Int32 nAttachedAxis = lcl_isSeriesAttachedToFirstAxis( xSeries )
++        //    ? ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y
++        //    : ::com::sun::star::chart::ChartAxisAssign::SECONDARY_Y;
++
++        Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
++        if( xSource.is())
++        {
++            // export series in correct order (as we don't store roles)
++            // with japanese candlesticks: open, low, high, close
++            // otherwise: low, high, close
++            Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(
++                xSource->getDataSequences());
++
++            //sal_Int32 nSeriesLength =
++            //    lcl_getSequenceLengthByRole( aSeqCnt, OUString::createFromAscii("values-last"));
++
++            Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY );
++            const char* sSeries[] = {"values-first","values-max","values-min","values-last",0};
++            for( sal_Int32 idx = 0; sSeries[idx] != 0 ; idx++ )
++            {
++                Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( lcl_getDataSequenceByRole( aSeqCnt, OUString::createFromAscii(sSeries[idx]) ) );
++                if( xLabeledSeq.is())
++                {
++                    Reference< chart2::data::XDataSequence > xLabelSeq( xLabeledSeq->getLabel());
++                    Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues());
++                        {
++                            FSHelperPtr pFS = GetFS();
++                            pFS->startElement( FSNS( XML_c, XML_ser ),
++                                FSEND );
++
++                            // TODO: idx and order
++                            pFS->singleElement( FSNS( XML_c, XML_idx ),
++                                XML_val, I32S(idx),
++                                FSEND );
++                            pFS->singleElement( FSNS( XML_c, XML_order ),
++                                XML_val, I32S(idx),
++                                FSEND );
++                            
++                            // export label
++                            if( xLabelSeq.is() )
++                                exportSeriesText( xLabelSeq );
++
++                            // TODO:export shape properties
++                            
++                            // export categories
++                            if( xCatSeq.is() )
++                                exportSeriesCategory( xCatSeq );
++                            
++                            // export values
++                            if( xValueSeq.is() )
++                                exportSeriesValues( xValueSeq );
++
++                            pFS->endElement( FSNS( XML_c, XML_ser ) );
++                        }
++                }
++            }
++        }
++    }
++}
++
++
++
 +void ChartExport::exportDataSeq( const Reference< chart2::data::XDataSequence > & xValueSeq, sal_Int32 elementTokenId )
 +{
 +    FSHelperPtr pFS = GetFS();
@@ -2668,13 +2853,11 @@ index 0000000..c300972
 +    pFS->endElement( FSNS( XML_c, XML_cat ) );
 +}
 +
-+void ChartExport::exportSeriesValues( const Reference< chart2::data::XDataSequence > & xValueSeq )
++void ChartExport::exportSeriesValues( const Reference< chart2::data::XDataSequence > & xValueSeq, sal_Int32 nValueType )
 +{
 +    FSHelperPtr pFS = GetFS();
 +    Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY );
-+    sal_Int32 nValueType = XML_val;
-+    //if( getChartType( xDiagram ) == chart::TYPEID_SCATTER )
-+    //    nValueType = XML_yVal;
++    // sal_Int32 nValueType = XML_val;
 +    pFS->startElement( FSNS( XML_c, nValueType ),
 +            FSEND );
 +
@@ -2791,240 +2974,200 @@ index 0000000..c300972
 +
 +void ChartExport::exportXAxis(
 +    Reference< ::com::sun::star::chart::XDiagram > xDiagram,
-+    Reference< chart2::XDiagram > xNewDiagram )
++    Reference< chart2::XDiagram > /*xNewDiagram*/ )
 +{
 +    // get some properties from document first
 +    sal_Bool bHasXAxisTitle = sal_False,
-+        bHasYAxisTitle = sal_False,
-+        bHasZAxisTitle = sal_False,
-+        bHasSecondaryXAxisTitle = sal_False,
-+        bHasSecondaryYAxisTitle = sal_False;
++        bHasSecondaryXAxisTitle = sal_False;
 +    sal_Bool bHasXAxisMajorGrid = sal_False,
-+        bHasXAxisMinorGrid = sal_False,
-+        bHasYAxisMajorGrid = sal_False,
-+        bHasYAxisMinorGrid = sal_False,
-+        bHasZAxisMajorGrid = sal_False,
-+        bHasZAxisMinorGrid = sal_False;
++        bHasXAxisMinorGrid = sal_False;
 +
 +   	Reference< XPropertySet > xDiagramProperties (xDiagram, uno::UNO_QUERY);
 +
 +    xDiagramProperties->getPropertyValue(
 +        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisTitle"))) >>= bHasXAxisTitle;
 +    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisTitle"))) >>=  bHasYAxisTitle;
-+    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisTitle"))) >>=  bHasZAxisTitle;
-+    xDiagramProperties->getPropertyValue(
 +        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasSecondaryXAxisTitle"))) >>=  bHasSecondaryXAxisTitle;
-+    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasSecondaryYAxisTitle"))) >>=  bHasSecondaryYAxisTitle;
 +
 +    xDiagramProperties->getPropertyValue(
 +        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisGrid"))) >>=  bHasXAxisMajorGrid;
-+    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisGrid"))) >>=  bHasYAxisMajorGrid;
-+    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisGrid"))) >>=  bHasZAxisMajorGrid;
 +
 +    xDiagramProperties->getPropertyValue(
 +        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisHelpGrid"))) >>=  bHasXAxisMinorGrid;
-+    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisHelpGrid"))) >>=  bHasYAxisMinorGrid;
-+    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisHelpGrid"))) >>=  bHasZAxisMinorGrid;
 +
 +    // catAx
 +    Reference< ::com::sun::star::chart::XAxisXSupplier > xAxisXSupp( xDiagram, uno::UNO_QUERY );
 +    if( !xAxisXSupp.is())
 +        return;
 +
-+    FSHelperPtr pFS = GetFS();
-+    Reference< XPropertySet > xPropSet;
-+    xPropSet = xAxisXSupp->getXAxis();
++    Reference< XPropertySet > xAxisProp = xAxisXSupp->getXAxis();
++    if( !xAxisProp.is() )
++        return;
 +
 +    sal_Int32 nAxisType = XML_catAx;
-+    if( getChartType( xDiagram ) == chart::TYPEID_SCATTER )
++    sal_Int32 eChartType = getChartType( xDiagram );
++    if( (eChartType == chart::TYPEID_SCATTER)
++        || (eChartType == chart::TYPEID_BUBBLE) )
 +        nAxisType = XML_valAx;
-+    pFS->startElement( FSNS( XML_c, nAxisType ),
-+            FSEND );
-+    pFS->singleElement( FSNS( XML_c, XML_axId ),
-+            XML_val, I32S( maAxisIdMap[ OUString(RTL_CONSTASCII_USTRINGPARAM("xAxis")) ] ),
-+            FSEND );
-+
-+    pFS->startElement( FSNS( XML_c, XML_scaling ),
-+            FSEND );
-+    //TODO:orientation: minMax, maxMin        
-+    const char* orientation = "minMax";
-+    pFS->singleElement( FSNS( XML_c, XML_orientation ),
-+            XML_val, orientation,
-+            FSEND );
-+    // logBase, min, max ??
-+    pFS->endElement( FSNS( XML_c, XML_scaling ) );
-+
-+    // title
-+    Reference< drawing::XShape > xShape( xAxisXSupp->getXAxisTitle(), uno::UNO_QUERY );
-+    if( bHasXAxisTitle && xShape.is() )
-+        exportTitle( xShape );
-+
-+    sal_Bool bVisible = sal_True;
-+    if( xPropSet.is() )
-+    {
-+        xPropSet->getPropertyValue(
-+            OUString (RTL_CONSTASCII_USTRINGPARAM ("Visible"))) >>=  bVisible;
-+    }        
++    else if( eChartType == chart::TYPEID_STOCK )
++        nAxisType = XML_dateAx;
++    
++    sal_Int32 nAxisId = maAxisIdMap[ OUString(RTL_CONSTASCII_USTRINGPARAM("xAxis")) ];
 +
-+    if( !bVisible )
-+    {
-+        // other value?
-+        pFS->singleElement( FSNS( XML_c, XML_delete ),
-+            XML_val, "1",
-+            FSEND );
-+    }
++    Reference< drawing::XShape > xAxisTitle;
++    if( bHasXAxisTitle )
++        xAxisTitle.set( xAxisXSupp->getXAxisTitle(), uno::UNO_QUERY );
 +
-+    // FIXME: axPos
++    // FIXME: axPos, need to check axis direction
 +    const char* sAxPos = "b";
-+    pFS->singleElement( FSNS( XML_c, XML_axPos ),
-+            XML_val, sAxPos,
-+            FSEND );
 +    // major grid line
-+    Reference< beans::XPropertySet > xMajorGrid( xAxisXSupp->getXMainGrid(), uno::UNO_QUERY );
-+    if( bHasXAxisMajorGrid && xMajorGrid.is())
-+    {
-+        pFS->startElement( FSNS( XML_c, XML_majorGridlines ),
-+            FSEND );
-+        exportShapeProps( xMajorGrid );
-+        pFS->endElement( FSNS( XML_c, XML_majorGridlines ) );
-+    }
++    Reference< beans::XPropertySet > xMajorGrid;
++    if( bHasXAxisMajorGrid )
++        xMajorGrid.set( xAxisXSupp->getXMainGrid(), uno::UNO_QUERY );
 +
 +    // minor grid line
-+    Reference< beans::XPropertySet > xMinorGrid( xAxisXSupp->getXHelpGrid(), uno::UNO_QUERY );
-+    if( bHasXAxisMinorGrid && xMinorGrid.is())
-+    {
-+        pFS->startElement( FSNS( XML_c, XML_minorGridlines ),
-+            FSEND );
-+        exportShapeProps( xMajorGrid );
-+        pFS->endElement( FSNS( XML_c, XML_minorGridlines ) );
-+    }
++    Reference< beans::XPropertySet > xMinorGrid;
++    if( bHasXAxisMinorGrid )
++        xMinorGrid.set( xAxisXSupp->getXHelpGrid(), uno::UNO_QUERY );
 +
-+    // FIXME: tickLblPos 
-+    const char* sTickLblPos = "nextTo";
-+    pFS->singleElement( FSNS( XML_c, XML_tickLblPos ),
-+            XML_val, sTickLblPos,
-+            FSEND );
-+            
-+    pFS->singleElement( FSNS( XML_c, XML_crossAx ),
-+            XML_val, I32S( maAxisIdMap[ OUString(RTL_CONSTASCII_USTRINGPARAM("yAxis")) ] ),
-+            FSEND );
-+    
-+    // FIXME: crosses 
-+    const char* sCrosses = "autoZero";
-+    pFS->singleElement( FSNS( XML_c, XML_crosses ),
-+            XML_val, sCrosses,
-+            FSEND );
-+    
-+    const char* isAuto = "1";
-+    pFS->singleElement( FSNS( XML_c, XML_auto ),
-+            XML_val, isAuto,
-+            FSEND );
-+    // FIXME: lblAlgn 
-+    const char* sLblAlgn = "ctr";
-+    pFS->singleElement( FSNS( XML_c, XML_lblAlgn ),
-+            XML_val, sLblAlgn,
-+            FSEND );
-+    // FIXME: lblOffset        
-+    sal_Int32 nLblOffset = 100;
-+    pFS->singleElement( FSNS( XML_c, XML_lblOffset ),
-+            XML_val, I32S( nLblOffset ),
-+            FSEND );
++    sal_Int32 nCrossAx =  maAxisIdMap[ OUString(RTL_CONSTASCII_USTRINGPARAM("yAxis")) ];
 +
-+    if( xPropSet.is())
-+    {
-+        // shape properties
-+        exportShapeProps( xPropSet );
-+        // TODO: text properties
-+    }
-+    
-+    pFS->endElement( FSNS( XML_c, nAxisType ) );
++    _exportAxis( xAxisProp, xAxisTitle, xMajorGrid, xMinorGrid, nAxisType, sAxPos, nAxisId, nCrossAx );
 +}
 +
 +void ChartExport::exportYAxis(
 +    Reference< ::com::sun::star::chart::XDiagram > xDiagram,
-+    Reference< chart2::XDiagram > xNewDiagram )
++    Reference< chart2::XDiagram >/* xNewDiagram */)
 +{
 +    // get some properties from document first
-+    sal_Bool bHasXAxisTitle = sal_False,
-+        bHasYAxisTitle = sal_False,
-+        bHasZAxisTitle = sal_False,
-+        bHasSecondaryXAxisTitle = sal_False,
++    sal_Bool bHasYAxisTitle = sal_False,
 +        bHasSecondaryYAxisTitle = sal_False;
-+    sal_Bool bHasXAxisMajorGrid = sal_False,
-+        bHasXAxisMinorGrid = sal_False,
-+        bHasYAxisMajorGrid = sal_False,
-+        bHasYAxisMinorGrid = sal_False,
-+        bHasZAxisMajorGrid = sal_False,
-+        bHasZAxisMinorGrid = sal_False;
++    sal_Bool bHasYAxisMajorGrid = sal_False,
++        bHasYAxisMinorGrid = sal_False;
 +
 +   	Reference< XPropertySet > xDiagramProperties (xDiagram, uno::UNO_QUERY);
 +
 +    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisTitle"))) >>= bHasXAxisTitle;
-+    xDiagramProperties->getPropertyValue(
 +        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisTitle"))) >>=  bHasYAxisTitle;
 +    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisTitle"))) >>=  bHasZAxisTitle;
-+    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasSecondaryXAxisTitle"))) >>=  bHasSecondaryXAxisTitle;
-+    xDiagramProperties->getPropertyValue(
 +        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasSecondaryYAxisTitle"))) >>=  bHasSecondaryYAxisTitle;
 +
 +    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisGrid"))) >>=  bHasXAxisMajorGrid;
-+    xDiagramProperties->getPropertyValue(
 +        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisGrid"))) >>=  bHasYAxisMajorGrid;
 +    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisGrid"))) >>=  bHasZAxisMajorGrid;
-+
-+    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisHelpGrid"))) >>=  bHasXAxisMinorGrid;
-+    xDiagramProperties->getPropertyValue(
 +        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisHelpGrid"))) >>=  bHasYAxisMinorGrid;
-+    xDiagramProperties->getPropertyValue(
-+        OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisHelpGrid"))) >>=  bHasZAxisMinorGrid;
 +
 +    Reference< ::com::sun::star::chart::XAxisYSupplier > xAxisYSupp( xDiagram, uno::UNO_QUERY );
 +    if( !xAxisYSupp.is())
 +        return;
 +
-+    FSHelperPtr pFS = GetFS();
-+    Reference< XPropertySet > xPropSet;
-+    xPropSet = xAxisYSupp->getYAxis();
++    Reference< XPropertySet > xAxisProp = xAxisYSupp->getYAxis();
++    if( !xAxisProp.is() )
++        return;
 +
 +    sal_Int32 nAxisType = XML_valAx;
++    sal_Int32 nAxisId = maAxisIdMap[ OUString(RTL_CONSTASCII_USTRINGPARAM("yAxis")) ];
++
++    Reference< drawing::XShape > xAxisTitle;
++    if( bHasYAxisTitle )
++        xAxisTitle.set( xAxisYSupp->getYAxisTitle(), uno::UNO_QUERY );
++
++    // FIXME: axPos
++    const char* sAxPos = "l";
++
++    // major grid line
++    Reference< beans::XPropertySet > xMajorGrid;
++    if( bHasYAxisMajorGrid )
++        xMajorGrid.set( xAxisYSupp->getYMainGrid(), uno::UNO_QUERY );
++
++    // minor grid line
++    Reference< beans::XPropertySet > xMinorGrid;( xAxisYSupp->getYHelpGrid(), uno::UNO_QUERY );
++    if( bHasYAxisMinorGrid )
++        xMinorGrid.set(  xAxisYSupp->getYHelpGrid(), uno::UNO_QUERY );
++
++    sal_Int32 nCrossAx = maAxisIdMap[ OUString(RTL_CONSTASCII_USTRINGPARAM("xAxis")) ];       
++    
++    _exportAxis( xAxisProp, xAxisTitle, xMajorGrid, xMinorGrid, nAxisType, sAxPos, nAxisId, nCrossAx );
++}
++
++void ChartExport::_exportAxis( 
++    const Reference< XPropertySet >& xAxisProp,
++    const Reference< drawing::XShape >& xAxisTitle,
++    const Reference< XPropertySet >& xMajorGrid,
++    const Reference< XPropertySet >& xMinorGrid,
++    sal_Int32 nAxisType,
++    const char* sAxisPos,
++    sal_Int32 nAxisId,
++    sal_Int32 nCrossAx )
++{
++    FSHelperPtr pFS = GetFS();
 +    pFS->startElement( FSNS( XML_c, nAxisType ),
 +            FSEND );
 +    pFS->singleElement( FSNS( XML_c, XML_axId ),
-+            XML_val, I32S( maAxisIdMap[ OUString(RTL_CONSTASCII_USTRINGPARAM("yAxis")) ] ),
++            XML_val, I32S( nAxisId ),
 +            FSEND );
 +
 +    pFS->startElement( FSNS( XML_c, XML_scaling ),
 +            FSEND );
-+    //TODO:orientation: minMax, maxMin        
-+    const char* orientation = "minMax";
++    // orientation: minMax, maxMin        
++    sal_Bool bReverseDirection = sal_False;
++    if(GetProperty( xAxisProp, S( "ReverseDirection" ) ) )
++        mAny >>= bReverseDirection;
++
++    const char* orientation = bReverseDirection ? "maxMin":"minMax";
 +    pFS->singleElement( FSNS( XML_c, XML_orientation ),
 +            XML_val, orientation,
 +            FSEND );
-+    // logBase, min, max ??
++    // logBase, min, max
++    if(GetProperty( xAxisProp, S( "Logarithmic" ) ) )
++    {
++        sal_Bool bLogarithmic = sal_False;
++        mAny >>= bLogarithmic;
++        if( bLogarithmic )
++        {
++            // default value is 10?
++            sal_Int32 nLogBase = 10;
++            pFS->singleElement( FSNS( XML_c, XML_logBase ),
++                XML_val, I32S( nLogBase ),
++                FSEND );
++        }
++    }
++    sal_Bool bAutoMax = sal_False;
++    if(GetProperty( xAxisProp, S( "AutoMax" ) ) )
++        mAny >>= bAutoMax;
++    
++    if( !bAutoMax && (GetProperty( xAxisProp, S( "Max" ) ) ))
++    {
++        double dMax = 0;
++        mAny >>= dMax;
++        pFS->singleElement( FSNS( XML_c, XML_max ),
++            XML_val, IS( dMax ),
++            FSEND );
++    }
++
++    sal_Bool bAutoMin = sal_False;
++    if(GetProperty( xAxisProp, S( "AutoMin" ) ) )
++        mAny >>= bAutoMax;
++    
++    if( !bAutoMin && (GetProperty( xAxisProp, S( "Min" ) ) ))
++    {
++        double dMin = 0;
++        mAny >>= dMin;
++        pFS->singleElement( FSNS( XML_c, XML_min ),
++            XML_val, IS( dMin ),
++            FSEND );
++    }
++
 +    pFS->endElement( FSNS( XML_c, XML_scaling ) );
 +
 +    // title
-+    Reference< drawing::XShape > xShape( xAxisYSupp->getYAxisTitle(), uno::UNO_QUERY );
-+    if( bHasYAxisTitle && xShape.is() )
-+        exportTitle( xShape );
++    if( xAxisTitle.is() )
++        exportTitle( xAxisTitle );
 +
 +    sal_Bool bVisible = sal_True;
-+    if( xPropSet.is() )
++    if( xAxisProp.is() )
 +    {
-+        xPropSet->getPropertyValue(
++        xAxisProp->getPropertyValue(
 +            OUString (RTL_CONSTASCII_USTRINGPARAM ("Visible"))) >>=  bVisible;
 +    }        
 +
@@ -3036,14 +3179,12 @@ index 0000000..c300972
 +            FSEND );
 +    }
 +
-+    // FIXME: axPos
-+    const char* sAxPos = "l";
++    // FIXME: axPos, need to check the property "ReverseDirection"
 +    pFS->singleElement( FSNS( XML_c, XML_axPos ),
-+            XML_val, sAxPos,
++            XML_val, sAxisPos,
 +            FSEND );
 +    // major grid line
-+    Reference< beans::XPropertySet > xMajorGrid( xAxisYSupp->getYMainGrid(), uno::UNO_QUERY );
-+    if( bHasYAxisMajorGrid && xMajorGrid.is())
++    if( xMajorGrid.is())
 +    {
 +        pFS->startElement( FSNS( XML_c, XML_majorGridlines ),
 +            FSEND );
@@ -3052,8 +3193,7 @@ index 0000000..c300972
 +    }
 +
 +    // minor grid line
-+    Reference< beans::XPropertySet > xMinorGrid( xAxisYSupp->getYHelpGrid(), uno::UNO_QUERY );
-+    if( bHasYAxisMinorGrid && xMinorGrid.is())
++    if( xMinorGrid.is())
 +    {
 +        pFS->startElement( FSNS( XML_c, XML_minorGridlines ),
 +            FSEND );
@@ -3061,41 +3201,178 @@ index 0000000..c300972
 +        pFS->endElement( FSNS( XML_c, XML_minorGridlines ) );
 +    }
 +
-+    // FIXME: tickLblPos 
-+    const char* sTickLblPos = "nextTo";
++    // majorTickMark
++    sal_Int32 nValue = 0;
++    if(GetProperty( xAxisProp, S( "Marks" ) ) )
++    {
++        mAny >>= nValue;
++        sal_Bool bInner = nValue & ::com::sun::star::chart::ChartAxisMarks::INNER;
++        sal_Bool bOuter = nValue & ::com::sun::star::chart::ChartAxisMarks::OUTER;
++        const char* majorTickMark = NULL;
++        if( bInner && bOuter )
++            majorTickMark = "cross";
++        else if( bInner )
++            majorTickMark = "in";
++        else if( bOuter )
++            majorTickMark = "out";
++        else
++            majorTickMark = "none";
++        pFS->singleElement( FSNS( XML_c, XML_majorTickMark ),
++            XML_val, majorTickMark,
++            FSEND );
++    }
++    // minorTickMark
++    if(GetProperty( xAxisProp, S( "HelpMarks" ) ) )
++    {
++        mAny >>= nValue;
++        sal_Bool bInner = nValue & ::com::sun::star::chart::ChartAxisMarks::INNER;
++        sal_Bool bOuter = nValue & ::com::sun::star::chart::ChartAxisMarks::OUTER;
++        const char* minorTickMark = NULL;
++        if( bInner && bOuter )
++            minorTickMark = "cross";
++        else if( bInner )
++            minorTickMark = "in";
++        else if( bOuter )
++            minorTickMark = "out";
++        else
++            minorTickMark = "none";
++        pFS->singleElement( FSNS( XML_c, XML_minorTickMark ),
++            XML_val, minorTickMark,
++            FSEND );
++    }
++    // tickLblPos 
++    const char* sTickLblPos = NULL;
++    sal_Bool bDisplayLabel = sal_True;
++    if(GetProperty( xAxisProp, S( "DisplayLabels" ) ) )
++        mAny >>= bDisplayLabel;
++    if( bDisplayLabel && (GetProperty( xAxisProp, S( "LabelPosition" ) ) ))
++    {
++        ::com::sun::star::chart::ChartAxisLabelPosition eLabelPosition = ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS;
++        mAny >>= eLabelPosition;
++        switch( eLabelPosition )
++        {
++            case ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS:
++            case ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS_OTHER_SIDE:
++                sTickLblPos = "nextTo";
++                break;
++            case ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START:
++                sTickLblPos = "low";
++                break;
++            case ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END:
++                sTickLblPos = "high";
++                break;
++            default:
++                sTickLblPos = "nextTo";
++                break;
++        }
++    }
++    else
++    {
++        sTickLblPos = "none";
++    }
 +    pFS->singleElement( FSNS( XML_c, XML_tickLblPos ),
 +            XML_val, sTickLblPos,
 +            FSEND );
 +            
 +    pFS->singleElement( FSNS( XML_c, XML_crossAx ),
-+            XML_val, I32S( maAxisIdMap[ OUString(RTL_CONSTASCII_USTRINGPARAM("xAxis")) ] ),
++            XML_val, I32S( nCrossAx ),
 +            FSEND );
 +    
-+    // FIXME: crosses 
-+    const char* sCrosses = "autoZero";
-+    pFS->singleElement( FSNS( XML_c, XML_crosses ),
++    // crosses & crossesAt
++    sal_Bool bCrossesValue = sal_False;
++    const char* sCrosses = NULL;
++    if(GetProperty( xAxisProp, S( "CrossoverPosition" ) ) )
++    {
++        ::com::sun::star::chart::ChartAxisPosition ePosition( ::com::sun::star::chart::ChartAxisPosition_ZERO );
++        mAny >>= ePosition;
++        switch( ePosition )
++        {
++            case ::com::sun::star::chart::ChartAxisPosition_START:
++                sCrosses = "min";
++                break;
++            case ::com::sun::star::chart::ChartAxisPosition_END:
++                sCrosses = "max";
++                break;
++            case ::com::sun::star::chart::ChartAxisPosition_ZERO:
++                sCrosses = "autoZero";
++                break;
++            default:
++                bCrossesValue = sal_True;
++                break;
++        }
++    }
++
++    if( bCrossesValue && GetProperty( xAxisProp, S("CrossoverValue" ) ) )
++    {
++        double dValue = 0;
++        mAny >>= dValue;
++        pFS->singleElement( FSNS( XML_c, XML_crossesAt ),
++            XML_val, IS( dValue ),
++            FSEND );
++    }
++    else
++    {
++        pFS->singleElement( FSNS( XML_c, XML_crosses ),
 +            XML_val, sCrosses,
 +            FSEND );
++    }        
 +    
-+    // FIXME: crossBetween 
-+    const char* sCrossBetween = "between";
-+    pFS->singleElement( FSNS( XML_c, XML_crossBetween ),
-+            XML_val, sCrossBetween,
++    if( nAxisType == XML_catAx )
++    {
++        // FIXME: seems not support? lblAlgn 
++        const char* sLblAlgn = "ctr";
++        pFS->singleElement( FSNS( XML_c, XML_lblAlgn ),
++            XML_val, sLblAlgn,
++            FSEND );
++    }        
++    if( ( nAxisType == XML_catAx )
++        || ( nAxisType == XML_dateAx ) )
++    {
++        // FIXME: seems not support? use default value,
++        const char* isAuto = "1";
++        pFS->singleElement( FSNS( XML_c, XML_auto ),
++            XML_val, isAuto,
++            FSEND );
++    
++        // FIXME: seems not support? lblOffset        
++        sal_Int32 nLblOffset = 100;
++        pFS->singleElement( FSNS( XML_c, XML_lblOffset ),
++            XML_val, I32S( nLblOffset ),
 +            FSEND );
++    }       
 +
-+    if( xPropSet.is())
++    // majorUnit
++    sal_Bool bAutoStepMain = sal_False;
++    if(GetProperty( xAxisProp, S( "AutoStepMain" ) ) )
++        mAny >>= bAutoStepMain;
++    
++    if( !bAutoStepMain && (GetProperty( xAxisProp, S( "StepMain" ) ) ))
 +    {
-+        // shape properties
-+        exportShapeProps( xPropSet );
-+        // TODO: text properties
++        double dMajorUnit = 0;
++        mAny >>= dMajorUnit;
++        pFS->singleElement( FSNS( XML_c, XML_majorUnit ),
++            XML_val, IS( dMajorUnit ),
++            FSEND );
 +    }
++    // minorUnit
++    sal_Bool bAutoStepHelp = sal_False;
++    if(GetProperty( xAxisProp, S( "AutoStepHelp" ) ) )
++        mAny >>= bAutoStepHelp;
 +    
-+    pFS->endElement( FSNS( XML_c, nAxisType ) );
-+
-+}
++    if( !bAutoStepHelp && (GetProperty( xAxisProp, S( "StepHelp" ) ) ))
++    {
++        double dMinorUnit = 0;
++        mAny >>= dMinorUnit;
++        pFS->singleElement( FSNS( XML_c, XML_minorUnit ),
++            XML_val, IS( dMinorUnit ),
++            FSEND );
++    }
 +
-+void ChartExport::exportGridLines( sal_Bool bHasMajorLine, sal_Bool bHasMinorLine )
-+{
++    // shape properties
++    exportShapeProps( xAxisProp );
++    // TODO: text properties
++    
++    pFS->endElement( FSNS( XML_c, nAxisType ) );
 +}
 +
 +void ChartExport::exportDataPoints(
@@ -3115,12 +3392,12 @@ index 0000000..c300972
 +            OUString( RTL_CONSTASCII_USTRINGPARAM( "VaryColorsByPoint" ))) >>= bVaryColorsByPoint;
 +    }
 +
-+    sal_Int32 nSize = aDataPointSeq.getLength();
-+    DBG_ASSERT( nSize <= nSeriesLength, "Too many point attributes" );
++    //sal_Int32 nSize = aDataPointSeq.getLength();
++    //DBG_ASSERT( nSize <= nSeriesLength, "Too many point attributes" );
 +
 +    const sal_Int32 * pPoints = aDataPointSeq.getConstArray();
 +    sal_Int32 nElement;
-+    sal_Int32 nRepeat;
++    //sal_Int32 nRepeat;
 +    Reference< chart2::XColorScheme > xColorScheme;
 +    if( xNewDiagram.is())
 +        xColorScheme.set( xNewDiagram->getDefaultColorScheme());
@@ -3186,7 +3463,6 @@ index 0000000..c300972
 +            XML_val, I32S( maAxisIdMap[ OUString(RTL_CONSTASCII_USTRINGPARAM("zAxis")) ] ),
 +            FSEND );
 +    }
-+
 +}
 +
 +}// drawingml


More information about the ooo-build-commit mailing list