[Libreoffice-commits] .: Branch 'libreoffice-3-4' - oox/source

Michael Meeks michael at kemper.freedesktop.org
Mon Jul 11 04:12:56 PDT 2011


 oox/source/drawingml/chart/axisconverter.cxx   |    4 ++++
 oox/source/drawingml/chart/chartconverter.cxx  |    6 +++---
 oox/source/drawingml/chart/seriesconverter.cxx |   14 ++++++++++++++
 3 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit d0df132019508db609fada9508504341d081fbbf
Author: Muthu Subramanian <sumuthu at novell.com>
Date:   Thu Jul 7 12:22:49 2011 +0530

    n#694356: Using formatcode while displaying labels.
    
    Used when the lables don't have their own formatcode
    and depend on the data's format code for formatting.
    
    Signed-off-by: Michael Meeks <michael.meeks at novell.com>

diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx
index 4cc2a8d..3c17c98 100644
--- a/oox/source/drawingml/chart/axisconverter.cxx
+++ b/oox/source/drawingml/chart/axisconverter.cxx
@@ -315,7 +315,11 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo
         // number format ------------------------------------------------------
 
         if( (aScaleData.AxisType == cssc2::AxisType::REALNUMBER) || (aScaleData.AxisType == cssc2::AxisType::PERCENT) )
+        {
+            if( mrModel.maNumberFormat.maFormatCode.indexOfAsciiL("%",1) >= 0)
+                mrModel.maNumberFormat.mbSourceLinked = false;
             getFormatter().convertNumberFormat( aAxisProp, mrModel.maNumberFormat );
+        }
 
         // position of crossing axis ------------------------------------------
 
diff --git a/oox/source/drawingml/chart/chartconverter.cxx b/oox/source/drawingml/chart/chartconverter.cxx
index 8f56b62..c9f44d0 100644
--- a/oox/source/drawingml/chart/chartconverter.cxx
+++ b/oox/source/drawingml/chart/chartconverter.cxx
@@ -59,7 +59,7 @@ static const sal_Unicode API_TOKEN_ARRAY_CLOSE     = '}';
 static const sal_Unicode API_TOKEN_ARRAY_ROWSEP    = '|';
 static const sal_Unicode API_TOKEN_ARRAY_COLSEP    = ';';
 
-// Code similar to oox/source/xls/FormulaParser.cxx
+// Code similar to oox/source/xls/formulabase.cxx
 static OUString lclGenerateApiString( const OUString& rString )
 {
     OUString aRetString = rString;
@@ -69,7 +69,7 @@ static OUString lclGenerateApiString( const OUString& rString )
     return OUStringBuffer().append( sal_Unicode( '"' ) ).append( aRetString ).append( sal_Unicode( '"' ) ).makeStringAndClear();
 }
 
-    static ::rtl::OUString lclGenerateApiArray( const Matrix< Any >& rMatrix )
+static ::rtl::OUString lclGenerateApiArray( const Matrix< Any >& rMatrix )
 {
     OSL_ENSURE( !rMatrix.empty(), "ChartConverter::lclGenerateApiArray - missing matrix values" );
     OUStringBuffer aBuffer;
@@ -156,7 +156,7 @@ Reference< XDataSequence > ChartConverter::createDataSequence( const Reference<
         }
         catch( Exception& )
         {
-            OSL_FAIL( "ExcelChartConverter::createDataSequence - cannot create data sequence" );
+            OSL_FAIL( "ChartConverter::createDataSequence - cannot create data sequence" );
         }
     }
 
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index 7b3d266..2a2564f 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -124,6 +124,13 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt
 
     bool bShowValue   = !rDataLabel.mbDeleted && rDataLabel.mobShowVal.get( false );
     bool bShowPercent = !rDataLabel.mbDeleted && rDataLabel.mobShowPercent.get( false ) && (rTypeInfo.meTypeCategory == TYPECATEGORY_PIE);
+    if( bShowValue &&
+        !bShowPercent && rTypeInfo.meTypeCategory == TYPECATEGORY_PIE &&
+        rDataLabel.maNumberFormat.maFormatCode.indexOfAsciiL("%", 1) >= 0 )
+    {
+        bShowValue = false;
+        bShowPercent = true;
+    }
     bool bShowCateg   = !rDataLabel.mbDeleted && rDataLabel.mobShowCatName.get( false );
     bool bShowSymbol  = !rDataLabel.mbDeleted && rDataLabel.mobShowLegendKey.get( false );
 
@@ -237,6 +244,7 @@ void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDa
     // data point label settings
     for( DataLabelsModel::DataLabelVector::iterator aIt = mrModel.maPointLabels.begin(), aEnd = mrModel.maPointLabels.end(); aIt != aEnd; ++aIt )
     {
+        (*aIt)->maNumberFormat.maFormatCode = mrModel.maNumberFormat.maFormatCode;
         DataLabelConverter aLabelConv( *this, **aIt );
         aLabelConv.convertFromModel( rxDataSeries, rTypeGroup );
     }
@@ -627,6 +635,12 @@ Reference< XDataSeries > SeriesConverter::createDataSeries( const TypeGroupConve
     ModelRef< DataLabelsModel > xLabels = mrModel.mxLabels.is() ? mrModel.mxLabels : rTypeGroup.getModel().mxLabels;
     if( xLabels.is() )
     {
+        if( xLabels->maNumberFormat.maFormatCode.isEmpty() )
+        {
+            // Use number format code from Value series
+            DataSourceModel* pValues = mrModel.maSources.get( SeriesModel::VALUES ).get();
+            xLabels->maNumberFormat.maFormatCode = pValues->mxDataSeq->maFormatCode;
+        }
         DataLabelsConverter aLabelsConv( *this, *xLabels );
         aLabelsConv.convertFromModel( xDataSeries, rTypeGroup );
     }


More information about the Libreoffice-commits mailing list