chart2/source/tools/ErrorBar.cxx   |    1 
 include/oox/export/chartexport.hxx |    3 
 oox/source/export/chartexport.cxx  |  177 ++++++++++++++++++++++++++++++++++---
 sc/source/filter/xml/xmlsubti.cxx  |    9 -
 4 files changed, 174 insertions(+), 16 deletions(-)

New commits:
commit e81d0c400c02a87d7fa492dbc5ac9f7921167920
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Mon Apr 29 00:12:07 2013 +0200

    change order to allow validation of chart part
    
    My simple test file is finally valid but is still now shown in Excel.
    There must be another bug in our exporter.
    
    Change-Id: Ib55e5b32edc3a556e9081b3008df539275dc289b

diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index 9198924..c3cf09f 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2188,6 +2188,9 @@ void ChartExport::_exportAxis(
             XML_val, sTickLblPos,
             FSEND );
 
+    // shape properties
+    exportShapeProps( xAxisProp );
+
     pFS->singleElement( FSNS( XML_c, XML_crossAx ),
             XML_val, I32S( aAxisIdPair.nCrossAx ),
             FSEND );
@@ -2282,8 +2285,6 @@ void ChartExport::_exportAxis(
             FSEND );
     }
 
-    // shape properties
-    exportShapeProps( xAxisProp );
     // TODO: text properties
 
     pFS->endElement( FSNS( XML_c, nAxisType ) );
commit 3812e99e939e6f3d8a6246c7adaa01de4e5abb99
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Sun Apr 28 23:59:24 2013 +0200

    another validation error with OOXML chart export
    
    c:characters does not have an attribute val. The value has to be written
    out as normal string.
    
    Change-Id: Icd2c4034918bd223d0c8082a7d137e1ce79a9cfe

diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index 128eceb..9198924 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2368,7 +2368,9 @@ void ChartExport::exportDataLabels(
                    if (GetProperty( xPropSet, "LabelSeparator"))
                    {
                        mAny >>= aSep;
-                       pFS->singleElement( FSNS( XML_c, XML_separator), 
XML_val, USS(aSep), FSEND);
+                       pFS->startElement( FSNS( XML_c, XML_separator), FSEND);
+                       pFS->writeEscaped(aSep);
+                       pFS->endElement( FSNS( XML_c, XML_separator) );
                    }
                    pFS->endElement( FSNS( XML_c, XML_dLbl ));
                }
commit 672398d84dcebba71ba996b07c7d47bb4257efef
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Sun Apr 28 23:58:29 2013 +0200

    order of element matters in OOXML export
    
    this fixes one validation error with documents containing charts
    
    Change-Id: I879963484b1cc00322e8c79bf77dfbbf91869587

diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index ea872b4..128eceb 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2352,24 +2352,24 @@ void ChartExport::exportDataLabels(
                    pFS->singleElement( FSNS( XML_c, XML_idx), XML_val, 
I32S(nElem), FSEND);
                    pFS->singleElement( FSNS( XML_c, XML_dLblPos), XML_val, 
aPlacement, FSEND);
 
-                   if (GetProperty( xPropSet, "LabelSeparator"))
-                   {
-                       mAny >>= aSep;
-                       pFS->singleElement( FSNS( XML_c, XML_separator), 
XML_val, USS(aSep), FSEND);
-                   }
-
                    pFS->singleElement( FSNS( XML_c, XML_showLegendKey), 
XML_val,
                                        aLabel.ShowLegendSymbol ? "1" : "0", 
FSEND);
                    pFS->singleElement( FSNS( XML_c, XML_showVal), XML_val,
                                        aLabel.ShowNumber ? "1" : "0", FSEND);
                    pFS->singleElement( FSNS( XML_c, XML_showCatName), XML_val,
                                        aLabel.ShowCategoryName ? "1" : "0", 
FSEND);
-                   pFS->singleElement( FSNS( XML_c, XML_showPercent), XML_val,
-                                       aLabel.ShowNumberInPercent ? "1" : "0", 
FSEND);
                    // MSO somehow assumes series name to be on (=displayed) by 
default.
                    // Let's put false here and switch it off then, since we 
have no UI means
                    // in LibO to toggle it on anyway
                    pFS->singleElement( FSNS( XML_c, XML_showSerName), XML_val, 
"0", FSEND);
+                   pFS->singleElement( FSNS( XML_c, XML_showPercent), XML_val,
+                                       aLabel.ShowNumberInPercent ? "1" : "0", 
FSEND);
+
+                   if (GetProperty( xPropSet, "LabelSeparator"))
+                   {
+                       mAny >>= aSep;
+                       pFS->singleElement( FSNS( XML_c, XML_separator), 
XML_val, USS(aSep), FSEND);
+                   }
                    pFS->endElement( FSNS( XML_c, XML_dLbl ));
                }
             }
commit 33671ee41300d762c8fc7a674a60efe152fffd45
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Sun Apr 28 23:45:08 2013 +0200

    export for error bars to OOXML, fdo#62312
    
    This does not work yet as we have several validation errors in our
    exported OOXML chart doc. I have to clean them up before the documents
    are accepted by Excel.
    
    Change-Id: I0bba64a9c6cab489199c8e6f04158fea7b953d0a

diff --git a/include/oox/export/chartexport.hxx 
b/include/oox/export/chartexport.hxx
index 10fc892..774ebb9 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -167,6 +167,9 @@ private:
     void exportSmooth();
     void exportFirstSliceAng();
 
+    void exportErrorBar(com::sun::star::uno::Reference< 
com::sun::star::beans::XPropertySet > xErrorBarProps,
+            bool bYError);
+
     void exportAxes( );
     void exportAxis( AxisIdPair aAxisIdPair );
     void _exportAxis(
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index 07b5371..ea872b4 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -43,6 +43,7 @@
 #include <com/sun/star/chart/ChartAxisPosition.hpp>
 #include <com/sun/star/chart/ChartSolidType.hpp>
 #include <com/sun/star/chart/DataLabelPlacement.hpp>
+#include <com/sun/star/chart/ErrorBarStyle.hpp>
 
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/chart2/XDiagram.hpp>
@@ -103,6 +104,8 @@ using ::com::sun::star::sheet::XFormulaTokens;
 using ::oox::core::XmlFilterBase;
 using ::sax_fastparser::FSHelperPtr;
 
+namespace cssc = com::sun::star::chart;
+
 DBG(extern void dump_pset(Reference< XPropertySet > rXPropSet));
 
 namespace oox { namespace drawingml {
@@ -1542,6 +1545,17 @@ void ChartExport::exportSeries( Reference< 
chart2::XChartType > xChartType, sal_
                     // export data points
                     exportDataPoints( uno::Reference< beans::XPropertySet >( 
aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ), nSeriesLength );
 
+                    //export error bars here
+                    Reference< XPropertySet > xSeriesPropSet( xSource, 
uno::UNO_QUERY );
+                    Reference< XPropertySet > xErrorBarYProps;
+                    xSeriesPropSet->getPropertyValue("ErrorBarY") >>= 
xErrorBarYProps;
+                    if(xErrorBarYProps.is())
+                        exportErrorBar(xErrorBarYProps, true);
+                    Reference< XPropertySet > xErrorBarXProps;
+                    xSeriesPropSet->getPropertyValue("ErrorBarX") >>= 
xErrorBarXProps;
+                    if(xErrorBarXProps.is())
+                        exportErrorBar(xErrorBarXProps, false);
+
                     // export categories
                     if( mxCategoriesValues.is() )
                         exportSeriesCategory( mxCategoriesValues );
@@ -2536,6 +2550,146 @@ void ChartExport::exportFirstSliceAng( )
             FSEND );
 }
 
+namespace {
+
+const char* getErrorBarStyle(sal_Int32 nErrorBarStyle)
+{
+    switch(nErrorBarStyle)
+    {
+        case cssc::ErrorBarStyle::NONE:
+            // I have no idea how to map it to OOXML
+            // this approach is as good as any else
+            return "fixedVal";
+        case cssc::ErrorBarStyle::VARIANCE:
+            break;
+        case cssc::ErrorBarStyle::STANDARD_DEVIATION:
+            return "stdDev";
+        case cssc::ErrorBarStyle::ABSOLUTE:
+            return "fixedVal";
+        case cssc::ErrorBarStyle::RELATIVE:
+            return "percentage";
+        case cssc::ErrorBarStyle::ERROR_MARGIN:
+            break;
+        case cssc::ErrorBarStyle::STANDARD_ERROR:
+            return "stdErr";
+        case cssc::ErrorBarStyle::FROM_DATA:
+            return "cust";
+        default:
+            assert(false); // can't happen
+    }
+    return "";
+}
+
+Reference< chart2::data::XDataSequence>  getLabeledSequence(
+        uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > 
aSequences,
+        bool bPositive )
+{
+    const OUString aRolePrefix( "error-bars" );
+    OUString aDirection;
+    if(bPositive)
+        aDirection = "positive";
+    else
+        aDirection = "negative";
+
+    for( sal_Int32 nI=0; nI< aSequences.getLength(); ++nI )
+    {
+        if( aSequences[nI].is())
+        {
+            uno::Reference< chart2::data::XDataSequence > xSequence( 
aSequences[nI]->getValues());
+            uno::Reference< beans::XPropertySet > xSeqProp( xSequence, 
uno::UNO_QUERY_THROW );
+            OUString aRole;
+            if( ( xSeqProp->getPropertyValue(
+                            OUString( "Role" )) >>= aRole ) &&
+                    aRole.match( aRolePrefix ) && aRole.indexOf(aDirection) >= 
0 )
+            {
+                return xSequence;
+            }
+        }
+    }
+
+    return Reference< chart2::data::XDataSequence > ();
+}
+
+}
+
+void ChartExport::exportErrorBar(Reference< XPropertySet> xErrorBarProps, bool 
bYError)
+{
+    FSHelperPtr pFS = GetFS();
+    pFS->startElement( FSNS( XML_c, XML_errBars ),
+            FSEND );
+    pFS->singleElement( FSNS( XML_c, XML_errDir ),
+            XML_val, bYError ? "y" : "x",
+            FSEND );
+    bool bPositive, bNegative;
+    xErrorBarProps->getPropertyValue("ShowPositiveError") >>= bPositive;
+    xErrorBarProps->getPropertyValue("ShowNegativeError") >>= bNegative;
+    const char* pErrBarType;
+    if(bPositive && bNegative)
+        pErrBarType = "both";
+    else if(bPositive)
+        pErrBarType = "plus";
+    else if(bNegative)
+        pErrBarType = "minus";
+    else
+    {
+        // what the hell should we do now?
+        // at least this makes the file valid
+        pErrBarType = "both";
+    }
+    pFS->singleElement( FSNS( XML_c, XML_errBarType ),
+            XML_val, pErrBarType,
+            FSEND );
+
+    sal_Int32 nErrorBarStyle;
+    xErrorBarProps->getPropertyValue("ErrorBarStyle") >>= nErrorBarStyle;
+    const char* pErrorBarStyle = getErrorBarStyle(nErrorBarStyle);
+    pFS->singleElement( FSNS( XML_c, XML_errValType ),
+            XML_val, pErrorBarStyle,
+            FSEND );
+    pFS->singleElement( FSNS( XML_c, XML_noEndCap ),
+            XML_val, "0",
+            FSEND );
+    if(nErrorBarStyle == cssc::ErrorBarStyle::FROM_DATA)
+    {
+        uno::Reference< chart2::data::XDataSource > 
xDataSource(xErrorBarProps, uno::UNO_QUERY);
+        Sequence< Reference < chart2::data::XLabeledDataSequence > > 
aSequences =
+            xDataSource->getDataSequences();
+
+        if(bPositive)
+        {
+            exportSeriesValues(getLabeledSequence(aSequences, true), XML_plus);
+        }
+
+        if(bNegative)
+        {
+            exportSeriesValues(getLabeledSequence(aSequences, false), 
XML_minus);
+        }
+    }
+    else
+    {
+        double nVal;
+        if(nErrorBarStyle == cssc::ErrorBarStyle::STANDARD_DEVIATION)
+        {
+            xErrorBarProps->getPropertyValue("Weight") >>= nVal;
+        }
+        else
+        {
+            if(bPositive)
+                xErrorBarProps->getPropertyValue("PositiveError") >>= nVal;
+            else
+                xErrorBarProps->getPropertyValue("NegativeError") >>= nVal;
+        }
+
+        OString aVal = OString::number(nVal);
+
+        pFS->singleElement( FSNS( XML_c, XML_val ),
+                XML_val, aVal.getStr(),
+                FSEND );
+    }
+
+    pFS->endElement( FSNS( XML_c, XML_errBars) );
+}
+
 void ChartExport::exportView3D()
 {
     Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY);
commit 3ba4b5a907530a93114177f30206f1bf81917464
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Sun Apr 28 23:44:36 2013 +0200

    remove this property temporarily until I understand the exception
    
    Change-Id: I74a4dfcebd61ca1b6befa9f49214e4155ce0bd34

diff --git a/chart2/source/tools/ErrorBar.cxx b/chart2/source/tools/ErrorBar.cxx
index cb78f8e..932efbc 100644
--- a/chart2/source/tools/ErrorBar.cxx
+++ b/chart2/source/tools/ErrorBar.cxx
@@ -65,7 +65,6 @@ const SfxItemPropertySet* GetErrorBarPropertySet()
         
{MAP_CHAR_LEN("ErrorBarRangeNegative"),7,&getCppuType((OUString*)0),0,0}, // 
read-only for export
         {MAP_CHAR_LEN("Weight"),8,&getCppuType((const double*)0),0,0},
         
{MAP_CHAR_LEN("LineStyle"),9,&getCppuType((com::sun::star::drawing::LineStyle*)0),0,0},
-        {MAP_CHAR_LEN("LineDashName"),10,&getCppuType((OUString*)0),0,0},
         {MAP_CHAR_LEN("LineDash"),10,&getCppuType((drawing::LineDash*)0),0,0},
         {MAP_CHAR_LEN("LineWidth"),11,&getCppuType((sal_Int32*)0),0,0},
         
{MAP_CHAR_LEN("LineColor"),12,&getCppuType((com::sun::star::util::Color*)0),0,0},
commit 4e3e171262aed0e52fa76158950d5be770249e80
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Fri Apr 26 10:54:34 2013 +0200

    use boost::scoped_ptr and direct values
    
    Change-Id: I70be33bc4843a19a24ce2fcb0cda094684557c04

diff --git a/sc/source/filter/xml/xmlsubti.cxx 
b/sc/source/filter/xml/xmlsubti.cxx
index a92abe7..b7d8ed3 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -283,15 +283,14 @@ void ScMyTables::AddMatrixRange(
     ScMarkData aMark;
     aMark.SetMarkArea( aScRange );
     aMark.SelectTable( aScRange.aStart.Tab(), sal_True );
-    ScTokenArray* pCode = new ScTokenArray;
+    boost::scoped_ptr<ScTokenArray> pCode(new ScTokenArray);
     pCode->AddStringXML( rFormula );
     if( (eGrammar == formula::FormulaGrammar::GRAM_EXTERNAL) && 
!rFormulaNmsp.isEmpty() )
         pCode->AddStringXML( rFormulaNmsp );
     pDoc->InsertMatrixFormula(
-        aScRange.aStart.Col(), aScRange.aStart.Row(),
-        aScRange.aEnd.Col(), aScRange.aEnd.Row(),
-        aMark, EMPTY_OUSTRING, pCode, eGrammar, false );
-    delete pCode;
+        nStartColumn, nStartRow,
+        nEndColumn, nEndRow,
+        aMark, EMPTY_OUSTRING, pCode.get(), eGrammar, false );
     pDoc->IncXMLImportedFormulaCount( rFormula.getLength() );
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to