LCOV - code coverage report
Current view: top level - sc/source/ui/vba - vbachart.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 366 4.6 %
Date: 2012-08-25 Functions: 2 35 5.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 759 0.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #include "vbachart.hxx"
      29                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      30                 :            : #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
      31                 :            : #include <com/sun/star/chart/XAxisXSupplier.hpp>
      32                 :            : #include <com/sun/star/chart/XAxisYSupplier.hpp>
      33                 :            : #include <com/sun/star/chart/XAxisZSupplier.hpp>
      34                 :            : #include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
      35                 :            : #include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
      36                 :            : #include <com/sun/star/chart/XChartDataArray.hpp>
      37                 :            : #include <com/sun/star/chart/ChartSymbolType.hpp>
      38                 :            : #include <com/sun/star/chart/ChartSolidType.hpp>
      39                 :            : #include <com/sun/star/chart/ChartDataRowSource.hpp>
      40                 :            : #include <com/sun/star/chart/ChartDataCaption.hpp>
      41                 :            : #include <ooo/vba/excel/XlChartType.hpp>
      42                 :            : #include <ooo/vba/excel/XlRowCol.hpp>
      43                 :            : #include <ooo/vba/excel/XlAxisType.hpp>
      44                 :            : #include <ooo/vba/excel/XlAxisGroup.hpp>
      45                 :            : 
      46                 :            : #include <basic/sberrors.hxx>
      47                 :            : #include "vbachartobject.hxx"
      48                 :            : #include "vbarange.hxx"
      49                 :            : #include "vbacharttitle.hxx"
      50                 :            : #include "vbaaxes.hxx"
      51                 :            : 
      52                 :            : using namespace ::com::sun::star;
      53                 :            : using namespace ::ooo::vba;
      54                 :            : using namespace ::ooo::vba::excel::XlChartType;
      55                 :            : using namespace ::ooo::vba::excel::XlRowCol;
      56                 :            : using namespace ::ooo::vba::excel::XlAxisType;
      57                 :            : using namespace ::ooo::vba::excel::XlAxisGroup;
      58                 :            : 
      59                 :          3 : const rtl::OUString CHART_NAME( RTL_CONSTASCII_USTRINGPARAM("Name") );
      60                 :            : // #TODO move this constant to vbaseries.[ch]xx ( when it exists )
      61                 :          3 : const rtl::OUString DEFAULTSERIESPREFIX( RTL_CONSTASCII_USTRINGPARAM("Series") );
      62                 :          3 : const rtl::OUString DATAROWSOURCE( RTL_CONSTASCII_USTRINGPARAM("DataRowSource") );
      63                 :          3 : const rtl::OUString UPDOWN( RTL_CONSTASCII_USTRINGPARAM("UpDown") );
      64                 :          3 : const rtl::OUString VOLUME( RTL_CONSTASCII_USTRINGPARAM("Volume") );
      65                 :          3 : const rtl::OUString LINES( RTL_CONSTASCII_USTRINGPARAM("Lines") );
      66                 :          3 : const rtl::OUString SPLINETYPE( RTL_CONSTASCII_USTRINGPARAM("SplineType") );
      67                 :          3 : const rtl::OUString SYMBOLTYPE( RTL_CONSTASCII_USTRINGPARAM("SymbolType") );
      68                 :          3 : const rtl::OUString DEEP( RTL_CONSTASCII_USTRINGPARAM("Deep") );
      69                 :          3 : const rtl::OUString SOLIDTYPE( RTL_CONSTASCII_USTRINGPARAM("SolidType") );
      70                 :          3 : const rtl::OUString VERTICAL( RTL_CONSTASCII_USTRINGPARAM("Vertical") );
      71                 :          3 : const rtl::OUString PERCENT( RTL_CONSTASCII_USTRINGPARAM("Percent") );
      72                 :          3 : const rtl::OUString STACKED( RTL_CONSTASCII_USTRINGPARAM("Stacked") );
      73                 :          3 : const rtl::OUString DIM3D( RTL_CONSTASCII_USTRINGPARAM("Dim3D") );
      74                 :          3 : const rtl::OUString HASMAINTITLE( RTL_CONSTASCII_USTRINGPARAM("HasMainTitle") );
      75                 :          3 : const rtl::OUString HASLEGEND( RTL_CONSTASCII_USTRINGPARAM("HasLegend") );
      76                 :            : 
      77         [ #  # ]:          0 : ScVbaChart::ScVbaChart( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const css::uno::Reference< css::lang::XComponent >& _xChartComponent, const css::uno::Reference< css::table::XTableChart >& _xTableChart ) : ChartImpl_BASE( _xParent, _xContext ), mxTableChart( _xTableChart )
      78                 :            : {
      79         [ #  # ]:          0 :     mxChartDocument.set( _xChartComponent, uno::UNO_QUERY_THROW ) ;
      80                 :            :     // #TODO is is possible that the XPropertySet interface is not set
      81                 :            :     // code in setPlotBy seems to indicate that this is possible? but
      82                 :            :     // additionally there is no check in most of the places where it is used
      83                 :            :     // ( and therefore could possibly be NULL )
      84                 :            :     // I'm going to let it throw for the moment ( npower )
      85 [ #  # ][ #  # ]:          0 :     mxDiagramPropertySet.set( mxChartDocument->getDiagram(), uno::UNO_QUERY_THROW );
                 [ #  # ]
      86         [ #  # ]:          0 :     mxChartPropertySet.set( _xChartComponent, uno::UNO_QUERY_THROW ) ;
      87                 :          0 : }
      88                 :            : 
      89                 :            : ::rtl::OUString SAL_CALL
      90                 :          0 : ScVbaChart::getName() throw (css::uno::RuntimeException)
      91                 :            : {
      92                 :          0 :     rtl::OUString sName;
      93         [ #  # ]:          0 :     uno::Reference< beans::XPropertySet > xProps( mxChartDocument, uno::UNO_QUERY_THROW );
      94                 :            :     try
      95                 :            :     {
      96 [ #  # ][ #  # ]:          0 :         xProps->getPropertyValue( CHART_NAME ) >>= sName;
      97                 :            :     }
      98         [ #  # ]:          0 :     catch( const uno::Exception & ) // swallow exceptions
      99                 :            :     {
     100                 :            :     }
     101         [ #  # ]:          0 :     return sName;
     102                 :            : }
     103                 :            : 
     104                 :            : uno::Any  SAL_CALL
     105                 :          0 : ScVbaChart::SeriesCollection(const uno::Any&) throw (uno::RuntimeException)
     106                 :            : {
     107                 :          0 :     return uno::Any();
     108                 :            : }
     109                 :            : 
     110                 :            : ::sal_Int32 SAL_CALL
     111                 :          0 : ScVbaChart::getChartType() throw ( uno::RuntimeException, script::BasicErrorException)
     112                 :            : {
     113                 :          0 :     sal_Int32 nChartType = -1;
     114                 :            :     try
     115                 :            :     {
     116 [ #  # ][ #  # ]:          0 :         rtl::OUString sDiagramType = mxChartDocument->getDiagram()->getDiagramType();
         [ #  # ][ #  # ]
     117         [ #  # ]:          0 :         if ( sDiagramType == "com.sun.star.chart.AreaDiagram" )
     118                 :            :         {
     119 [ #  # ][ #  # ]:          0 :             if (is3D())
     120                 :            :             {
     121         [ #  # ]:          0 :                 nChartType = getStackedType(xl3DAreaStacked, xl3DAreaStacked100, xl3DArea);
     122                 :            :             }
     123                 :            :             else
     124                 :            :             {
     125         [ #  # ]:          0 :                 nChartType = getStackedType(xlAreaStacked, xlAreaStacked100, xlArea);
     126                 :            :             }
     127                 :            :         }
     128         [ #  # ]:          0 :         else if ( sDiagramType == "com.sun.star.chart.PieDiagram" )
     129                 :            :         {
     130 [ #  # ][ #  # ]:          0 :             if (is3D())
     131                 :          0 :                 nChartType = xl3DPie;
     132                 :            :             else
     133                 :          0 :                 nChartType = xlPie;                 /*TODO XlChartType  xlPieExploded, XlChartType xlPieOfPie */
     134                 :            :         }
     135         [ #  # ]:          0 :         else if ( sDiagramType == "com.sun.star.chart.BarDiagram" )
     136                 :            :         {
     137                 :          0 :             sal_Int32 nSolidType = chart::ChartSolidType::RECTANGULAR_SOLID;
     138 [ #  # ][ #  # ]:          0 :             if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SOLIDTYPE))
         [ #  # ][ #  # ]
                 [ #  # ]
     139                 :            :             {       //in 2D diagrams 'SolidType' may not be set
     140 [ #  # ][ #  # ]:          0 :                 if (is3D())
     141 [ #  # ][ #  # ]:          0 :                     mxDiagramPropertySet->getPropertyValue(SOLIDTYPE) >>= nSolidType;
     142                 :            :             }
     143   [ #  #  #  # ]:          0 :             switch (nSolidType)
     144                 :            :             {
     145                 :            :                 case chart::ChartSolidType::CONE:
     146         [ #  # ]:          0 :                     nChartType = getSolidType(xlConeCol, xlConeColStacked, xlConeColStacked100, xlConeColClustered, xlConeBarStacked, xlConeBarStacked100, xlConeBarClustered);
     147                 :          0 :                     break;
     148                 :            :                 case chart::ChartSolidType::CYLINDER:
     149         [ #  # ]:          0 :                     nChartType = getSolidType(xlCylinderCol, xlCylinderColStacked, xlCylinderColStacked100, xlCylinderColClustered, xlCylinderBarStacked, xlCylinderBarStacked100, xlCylinderBarClustered);
     150                 :          0 :                     break;
     151                 :            :                 case chart::ChartSolidType::PYRAMID:
     152         [ #  # ]:          0 :                     nChartType = getSolidType(xlPyramidCol, xlPyramidColStacked, xlPyramidColStacked100, xlPyramidColClustered, xlPyramidBarStacked, xlPyramidBarStacked100, xlPyramidBarClustered);
     153                 :          0 :                     break;
     154                 :            :                 default: // RECTANGULAR_SOLID
     155 [ #  # ][ #  # ]:          0 :                     if (is3D())
     156                 :            :                     {
     157         [ #  # ]:          0 :                         nChartType = getSolidType(xl3DColumn, xl3DColumnStacked, xl3DColumnStacked100, xl3DColumnClustered, xl3DBarStacked, xl3DBarStacked100, xl3DBarClustered);
     158                 :            :                     }
     159                 :            :                     else
     160                 :            :                     {
     161         [ #  # ]:          0 :                         nChartType = getSolidType(xlColumnClustered,  xlColumnStacked, xlColumnStacked100, xlColumnClustered, xlBarStacked, xlBarStacked100, xlBarClustered);
     162                 :            :                     }
     163                 :          0 :                     break;
     164                 :            :                 }
     165                 :            :             }
     166         [ #  # ]:          0 :         else if ( sDiagramType == "com.sun.star.chart.StockDiagram" )
     167                 :            :         {
     168                 :          0 :             sal_Bool bVolume = false;
     169 [ #  # ][ #  # ]:          0 :             mxDiagramPropertySet->getPropertyValue(VOLUME) >>= bVolume;
     170         [ #  # ]:          0 :             if (bVolume)
     171                 :            :             {
     172         [ #  # ]:          0 :                 nChartType = getStockUpDownValue(xlStockVOHLC, xlStockVHLC);
     173                 :            :             }
     174                 :            :             else
     175                 :            :             {
     176         [ #  # ]:          0 :                 nChartType = getStockUpDownValue(xlStockOHLC, xlStockHLC);
     177                 :            :             }
     178                 :            :         }
     179         [ #  # ]:          0 :         else if ( sDiagramType == "com.sun.star.chart.XYDiagram" )
     180                 :            :         {
     181                 :          0 :             sal_Bool bHasLines = false;
     182 [ #  # ][ #  # ]:          0 :             mxDiagramPropertySet->getPropertyValue(LINES) >>= bHasLines;
     183                 :          0 :             sal_Int32 nSplineType = 0;
     184 [ #  # ][ #  # ]:          0 :             mxDiagramPropertySet->getPropertyValue(SPLINETYPE) >>= nSplineType;
     185         [ #  # ]:          0 :             if (nSplineType == 1)
     186                 :            :             {
     187         [ #  # ]:          0 :                 nChartType = getMarkerType(xlXYScatterSmooth, xlXYScatterSmoothNoMarkers);
     188                 :            :             }
     189         [ #  # ]:          0 :             else if (bHasLines)
     190                 :            :             {
     191         [ #  # ]:          0 :                 nChartType = getMarkerType(xlXYScatterLines, xlXYScatterLinesNoMarkers);
     192                 :            :             }
     193                 :            :             else
     194                 :            :             {
     195                 :          0 :                 nChartType = xlXYScatter;
     196                 :            :             }
     197                 :            :         }
     198         [ #  # ]:          0 :         else if ( sDiagramType == "com.sun.star.chart.LineDiagram" )
     199                 :            :         {
     200 [ #  # ][ #  # ]:          0 :             if (is3D())
     201                 :            :             {
     202                 :          0 :                 nChartType = xl3DLine;
     203                 :            :             }
     204 [ #  # ][ #  # ]:          0 :             else if (hasMarkers())
     205                 :            :             {
     206         [ #  # ]:          0 :                 nChartType = getStackedType(xlLineMarkersStacked, xlLineMarkersStacked100, xlLineMarkers);
     207                 :            :             }
     208                 :            :             else
     209                 :            :             {
     210         [ #  # ]:          0 :                 nChartType = getStackedType(xlLineStacked, xlLineStacked100, xlLine);
     211                 :            :             }
     212                 :            :         }
     213         [ #  # ]:          0 :         else if ( sDiagramType == "com.sun.star.chart.DonutDiagram" )
     214                 :            :         {
     215                 :          0 :             nChartType = xlDoughnut;                    // TODO DoughnutExploded ??
     216                 :            :         }
     217         [ #  # ]:          0 :         else if ( sDiagramType == "com.sun.star.chart.NetDiagram" )
     218                 :            :         {
     219         [ #  # ]:          0 :             nChartType = getMarkerType(xlRadarMarkers, xlRadar);
     220                 :          0 :         }
     221                 :            :     }
     222         [ #  # ]:          0 :     catch ( const uno::Exception& )
     223                 :            :     {
     224         [ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     225                 :            :     }
     226                 :          0 :     return nChartType;
     227                 :            : }
     228                 :            : 
     229                 :            : void SAL_CALL
     230                 :          0 : ScVbaChart::setChartType( ::sal_Int32 _nChartType ) throw ( uno::RuntimeException, script::BasicErrorException)
     231                 :            : {
     232                 :            : try
     233                 :            : {
     234   [ #  #  #  #  :          0 :     switch (_nChartType)
             #  #  #  #  
                      # ]
     235                 :            :     {
     236                 :            :         case xlColumnClustered:
     237                 :            :         case xlColumnStacked:
     238                 :            :         case xlColumnStacked100:
     239                 :            :         case xl3DColumnClustered:
     240                 :            :         case xl3DColumnStacked:
     241                 :            :         case xl3DColumnStacked100:
     242                 :            :         case xl3DColumn:
     243                 :            :         case xlBarClustered:
     244                 :            :         case xlBarStacked:
     245                 :            :         case xlBarStacked100:
     246                 :            :         case xl3DBarClustered:
     247                 :            :         case xl3DBarStacked:
     248                 :            :         case xl3DBarStacked100:
     249                 :            :         case xlConeColClustered:
     250                 :            :         case xlConeColStacked:
     251                 :            :         case xlConeColStacked100:
     252                 :            :         case xlConeBarClustered:
     253                 :            :         case xlConeBarStacked:
     254                 :            :         case xlConeBarStacked100:
     255                 :            :         case xlConeCol:
     256                 :            :         case xlPyramidColClustered:
     257                 :            :         case xlPyramidColStacked:
     258                 :            :         case xlPyramidColStacked100:
     259                 :            :         case xlPyramidBarClustered:
     260                 :            :         case xlPyramidBarStacked:
     261                 :            :         case xlPyramidBarStacked100:
     262                 :            :         case xlPyramidCol:
     263                 :            :         case xlCylinderColClustered:
     264                 :            :         case xlCylinderColStacked:
     265                 :            :         case xlCylinderColStacked100:
     266                 :            :         case xlCylinderBarClustered:
     267                 :            :         case xlCylinderBarStacked:
     268                 :            :         case xlCylinderBarStacked100:
     269                 :            :         case xlCylinderCol:
     270                 :            :         case xlSurface: // not possible
     271                 :            :         case xlSurfaceWireframe:
     272                 :            :         case xlSurfaceTopView:
     273                 :            :         case xlSurfaceTopViewWireframe:
     274 [ #  # ][ #  # ]:          0 :             setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.BarDiagram")));
     275                 :          0 :             break;
     276                 :            :         case xlLine:
     277                 :            :         case xl3DLine:
     278                 :            :         case xlLineStacked:
     279                 :            :         case xlLineStacked100:
     280                 :            :         case xlLineMarkers:
     281                 :            :         case xlLineMarkersStacked:
     282                 :            :         case xlLineMarkersStacked100:
     283 [ #  # ][ #  # ]:          0 :             setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.LineDiagram")));
     284                 :          0 :             break;
     285                 :            :         case xl3DArea:
     286                 :            :         case xlArea:
     287                 :            :         case xlAreaStacked:
     288                 :            :         case xlAreaStacked100:
     289                 :            :         case xl3DAreaStacked:
     290                 :            :         case xl3DAreaStacked100:
     291 [ #  # ][ #  # ]:          0 :             setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.AreaDiagram")) );
     292                 :          0 :             break;
     293                 :            :         case xlDoughnut:
     294                 :            :         case xlDoughnutExploded:
     295 [ #  # ][ #  # ]:          0 :             setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.DonutDiagram") ) );
     296                 :          0 :             break;
     297                 :            :         case xlStockHLC:
     298                 :            :         case xlStockOHLC:
     299                 :            :         case xlStockVHLC:
     300                 :            :         case xlStockVOHLC:
     301 [ #  # ][ #  # ]:          0 :             setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.StockDiagram")));
     302 [ #  # ][ #  # ]:          0 :             mxDiagramPropertySet->setPropertyValue( UPDOWN, uno::makeAny(sal_Bool((_nChartType == xlStockOHLC) || (_nChartType == xlStockVOHLC))));
         [ #  # ][ #  # ]
                 [ #  # ]
     303 [ #  # ][ #  # ]:          0 :             mxDiagramPropertySet->setPropertyValue(VOLUME, uno::makeAny(sal_Bool((_nChartType == xlStockVHLC) || (_nChartType == xlStockVOHLC))));
         [ #  # ][ #  # ]
                 [ #  # ]
     304                 :          0 :             break;
     305                 :            : 
     306                 :            :         case xlPieOfPie:                            // not possible
     307                 :            :         case xlPieExploded: // SegmentOffset an ChartDataPointProperties ->am XDiagram abholen //wie macht Excel das?
     308                 :            :         case xl3DPieExploded:
     309                 :            :         case xl3DPie:
     310                 :            :         case xlPie:
     311                 :            :         case xlBarOfPie:                            // not possible (Zoom pie)
     312 [ #  # ][ #  # ]:          0 :             setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.PieDiagram")));
     313                 :          0 :             break;
     314                 :            : 
     315                 :            :         case xlRadar:
     316                 :            :         case xlRadarMarkers:
     317                 :            :         case xlRadarFilled:
     318 [ #  # ][ #  # ]:          0 :             setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.NetDiagram")));
     319                 :          0 :             break;
     320                 :            :         case xlXYScatter:
     321                 :            :         case xlBubble:                      // not possible
     322                 :            :         case xlBubble3DEffect:              // not possible
     323                 :            :         case xlXYScatterLines:
     324                 :            :         case xlXYScatterLinesNoMarkers:
     325                 :            :         case xlXYScatterSmooth:
     326                 :            :         case xlXYScatterSmoothNoMarkers:
     327 [ #  # ][ #  # ]:          0 :             setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.XYDiagram")));
     328   [ #  #  #  # ]:          0 :             switch(_nChartType)
     329                 :            :             {
     330                 :            :                 case xlXYScatter:
     331                 :            :                 case xlBubble:                      // not possible
     332                 :            :                 case xlBubble3DEffect:              // not possible
     333 [ #  # ][ #  # ]:          0 :                     mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( sal_False ));
                 [ #  # ]
     334                 :          0 :                     break;
     335                 :            :                 case xlXYScatterLines:
     336                 :            :                 case xlXYScatterLinesNoMarkers:
     337 [ #  # ][ #  # ]:          0 :                     mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( sal_True ));
                 [ #  # ]
     338                 :          0 :                     break;
     339                 :            :                 case xlXYScatterSmooth:
     340                 :            :                 case xlXYScatterSmoothNoMarkers:
     341 [ #  # ][ #  # ]:          0 :                     mxDiagramPropertySet->setPropertyValue(SPLINETYPE, uno::makeAny( sal_Int32(1)));
                 [ #  # ]
     342                 :          0 :                     break;
     343                 :            :                 default:
     344                 :          0 :                     break;
     345                 :            :             }
     346                 :          0 :             break;
     347                 :            :         default:
     348         [ #  # ]:          0 :             throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_CONVERSION, rtl::OUString() );
     349                 :            :     }
     350                 :            : 
     351         [ #  # ]:          0 :     switch (_nChartType)
     352                 :            :     {
     353                 :            :         case xlLineMarkers:
     354                 :            :         case xlLineMarkersStacked:
     355                 :            :         case xlLineMarkersStacked100:
     356                 :            :         case xlRadarMarkers:
     357                 :            :         case xlXYScatterLines:
     358                 :            :         case xlXYScatterSmooth:
     359                 :            :         case xlXYScatter:
     360                 :            :         case xlBubble:                      // not possible
     361                 :            :         case xlBubble3DEffect:              // not possible
     362 [ #  # ][ #  # ]:          0 :             mxDiagramPropertySet->setPropertyValue(SYMBOLTYPE, uno::makeAny( chart::ChartSymbolType::AUTO));
                 [ #  # ]
     363                 :          0 :             break;
     364                 :            :         default:
     365 [ #  # ][ #  # ]:          0 :             if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SYMBOLTYPE))
         [ #  # ][ #  # ]
                 [ #  # ]
     366                 :            :             {
     367 [ #  # ][ #  # ]:          0 :                 mxDiagramPropertySet->setPropertyValue(SYMBOLTYPE, uno::makeAny(chart::ChartSymbolType::NONE));
                 [ #  # ]
     368                 :            :             }
     369                 :          0 :             break;
     370                 :            :     }
     371                 :            : 
     372         [ #  # ]:          0 :     switch (_nChartType)
     373                 :            :     {
     374                 :            :         case xlConeCol:
     375                 :            :         case xlPyramidCol:
     376                 :            :         case xlCylinderCol:
     377                 :            :         case xl3DColumn:
     378                 :            :         case xlSurface:                         // not possible
     379                 :            :         case xlSurfaceWireframe:
     380                 :            :         case xlSurfaceTopView:
     381                 :            :         case xlSurfaceTopViewWireframe:
     382 [ #  # ][ #  # ]:          0 :             mxDiagramPropertySet->setPropertyValue(DEEP,uno::makeAny( sal_True ));
                 [ #  # ]
     383                 :          0 :             break;
     384                 :            :         default:
     385 [ #  # ][ #  # ]:          0 :                 if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DEEP))
         [ #  # ][ #  # ]
                 [ #  # ]
     386                 :            :                 {
     387 [ #  # ][ #  # ]:          0 :                     mxDiagramPropertySet->setPropertyValue(DEEP, uno::makeAny( sal_False));
                 [ #  # ]
     388                 :            :                 }
     389                 :          0 :                 break;
     390                 :            :         }
     391                 :            : 
     392                 :            : 
     393   [ #  #  #  # ]:          0 :         switch (_nChartType)
     394                 :            :         {
     395                 :            :                 case xlConeColClustered:
     396                 :            :                 case xlConeColStacked:
     397                 :            :                 case xlConeColStacked100:
     398                 :            :                 case xlConeBarClustered:
     399                 :            :                 case xlConeBarStacked:
     400                 :            :                 case xlConeBarStacked100:
     401                 :            :                 case xlConeCol:
     402 [ #  # ][ #  # ]:          0 :                         mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::CONE));
                 [ #  # ]
     403                 :          0 :                         break;
     404                 :            :                 case xlPyramidColClustered:
     405                 :            :                 case xlPyramidColStacked:
     406                 :            :                 case xlPyramidColStacked100:
     407                 :            :                 case xlPyramidBarClustered:
     408                 :            :                 case xlPyramidBarStacked:
     409                 :            :                 case xlPyramidBarStacked100:
     410                 :            :                 case xlPyramidCol:
     411 [ #  # ][ #  # ]:          0 :                         mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::PYRAMID));
                 [ #  # ]
     412                 :          0 :                         break;
     413                 :            :                 case xlCylinderColClustered:
     414                 :            :                 case xlCylinderColStacked:
     415                 :            :                 case xlCylinderColStacked100:
     416                 :            :                 case xlCylinderBarClustered:
     417                 :            :                 case xlCylinderBarStacked:
     418                 :            :                 case xlCylinderBarStacked100:
     419                 :            :                 case xlCylinderCol:
     420 [ #  # ][ #  # ]:          0 :                         mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::CYLINDER));
                 [ #  # ]
     421                 :          0 :                         break;
     422                 :            :                 default:
     423 [ #  # ][ #  # ]:          0 :                     if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SOLIDTYPE))
         [ #  # ][ #  # ]
                 [ #  # ]
     424                 :            :                     {
     425 [ #  # ][ #  # ]:          0 :                             mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::RECTANGULAR_SOLID));
                 [ #  # ]
     426                 :            :                     }
     427                 :          0 :                     break;
     428                 :            :         }
     429                 :            : 
     430         [ #  # ]:          0 :         switch ( _nChartType)
     431                 :            :         {
     432                 :            :             case xlConeCol:
     433                 :            :             case xlConeColClustered:
     434                 :            :             case xlConeColStacked:
     435                 :            :             case xlConeColStacked100:
     436                 :            :             case xlPyramidColClustered:
     437                 :            :             case xlPyramidColStacked:
     438                 :            :             case xlPyramidColStacked100:
     439                 :            :             case xlCylinderColClustered:
     440                 :            :             case xlCylinderColStacked:
     441                 :            :             case xlCylinderColStacked100:
     442                 :            :             case xlColumnClustered:
     443                 :            :             case xlColumnStacked:
     444                 :            :             case xlColumnStacked100:
     445                 :            :             case xl3DColumnClustered:
     446                 :            :             case xl3DColumnStacked:
     447                 :            :             case xl3DColumnStacked100:
     448                 :            :             case xlSurface: // not possible
     449                 :            :             case xlSurfaceWireframe:
     450                 :            :             case xlSurfaceTopView:
     451                 :            :             case xlSurfaceTopViewWireframe:
     452 [ #  # ][ #  # ]:          0 :                 mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny( sal_True));
                 [ #  # ]
     453                 :          0 :                 break;
     454                 :            :             default:
     455 [ #  # ][ #  # ]:          0 :                 if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(VERTICAL))
         [ #  # ][ #  # ]
                 [ #  # ]
     456                 :            :                 {
     457 [ #  # ][ #  # ]:          0 :                     mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny(sal_False));
                 [ #  # ]
     458                 :            :                 }
     459                 :          0 :                 break;
     460                 :            :         }
     461                 :            : 
     462      [ #  #  # ]:          0 :         switch (_nChartType)
     463                 :            :         {
     464                 :            :             case xlColumnStacked:
     465                 :            :             case xl3DColumnStacked:
     466                 :            :             case xlBarStacked:
     467                 :            :             case xl3DBarStacked:
     468                 :            :             case xlLineStacked:
     469                 :            :             case xlLineMarkersStacked:
     470                 :            :             case xlAreaStacked:
     471                 :            :             case xl3DAreaStacked:
     472                 :            :             case xlCylinderColStacked:
     473                 :            :             case xlCylinderBarStacked:
     474                 :            :             case xlConeColStacked:
     475                 :            :             case xlConeBarStacked:
     476                 :            :             case xlPyramidColStacked:
     477                 :            :             case xlPyramidBarStacked:
     478 [ #  # ][ #  # ]:          0 :                 mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False ));
                 [ #  # ]
     479 [ #  # ][ #  # ]:          0 :                 mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_True ));
                 [ #  # ]
     480                 :          0 :                 break;
     481                 :            :             case xlPyramidColStacked100:
     482                 :            :             case xlPyramidBarStacked100:
     483                 :            :             case xlConeColStacked100:
     484                 :            :             case xlConeBarStacked100:
     485                 :            :             case xlCylinderBarStacked100:
     486                 :            :             case xlCylinderColStacked100:
     487                 :            :             case xl3DAreaStacked100:
     488                 :            :             case xlLineMarkersStacked100:
     489                 :            :             case xlAreaStacked100:
     490                 :            :             case xlLineStacked100:
     491                 :            :             case xl3DBarStacked100:
     492                 :            :             case xlBarStacked100:
     493                 :            :             case xl3DColumnStacked100:
     494                 :            :             case xlColumnStacked100:
     495 [ #  # ][ #  # ]:          0 :                 mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_True));
                 [ #  # ]
     496 [ #  # ][ #  # ]:          0 :                 mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_True ));
                 [ #  # ]
     497                 :          0 :                 break;
     498                 :            :             default:
     499 [ #  # ][ #  # ]:          0 :                 mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False));
                 [ #  # ]
     500 [ #  # ][ #  # ]:          0 :                 mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_False));
                 [ #  # ]
     501                 :          0 :                 break;
     502                 :            :         }
     503         [ #  # ]:          0 :         switch (_nChartType)
     504                 :            :         {
     505                 :            :             case xl3DArea:
     506                 :            :             case xl3DAreaStacked:
     507                 :            :             case xl3DAreaStacked100:
     508                 :            :             case xl3DBarClustered:
     509                 :            :             case xl3DBarStacked:
     510                 :            :             case xl3DBarStacked100:
     511                 :            :             case xl3DColumn:
     512                 :            :             case xl3DColumnClustered:
     513                 :            :             case xl3DColumnStacked:
     514                 :            :             case xl3DColumnStacked100:
     515                 :            :             case xl3DLine:
     516                 :            :             case xl3DPie:
     517                 :            :             case xl3DPieExploded:
     518                 :            :             case xlConeColClustered:
     519                 :            :             case xlConeColStacked:
     520                 :            :             case xlConeColStacked100:
     521                 :            :             case xlConeBarClustered:
     522                 :            :             case xlConeBarStacked:
     523                 :            :             case xlConeBarStacked100:
     524                 :            :             case xlConeCol:
     525                 :            :             case xlPyramidColClustered:
     526                 :            :             case xlPyramidColStacked:
     527                 :            :             case xlPyramidColStacked100:
     528                 :            :             case xlPyramidBarClustered:
     529                 :            :             case xlPyramidBarStacked:
     530                 :            :             case xlPyramidBarStacked100:
     531                 :            :             case xlPyramidCol:
     532                 :            :             case xlCylinderColClustered:
     533                 :            :             case xlCylinderColStacked:
     534                 :            :             case xlCylinderColStacked100:
     535                 :            :             case xlCylinderBarClustered:
     536                 :            :             case xlCylinderBarStacked:
     537                 :            :             case xlCylinderBarStacked100:
     538                 :            :             case xlCylinderCol:
     539 [ #  # ][ #  # ]:          0 :                 mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( sal_True));
                 [ #  # ]
     540                 :          0 :                 break;
     541                 :            :             default:
     542 [ #  # ][ #  # ]:          0 :                 if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DIM3D))
         [ #  # ][ #  # ]
                 [ #  # ]
     543                 :            :                 {
     544 [ #  # ][ #  # ]:          0 :                     mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( sal_False));
                 [ #  # ]
     545                 :            :                 }
     546                 :          0 :                 break;
     547                 :            :         }
     548                 :            :     }
     549         [ #  # ]:          0 :     catch ( const uno::Exception& )
     550                 :            :     {
     551         [ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     552                 :            :     }
     553                 :          0 : }
     554                 :            : 
     555                 :            : void SAL_CALL
     556                 :          0 : ScVbaChart::Activate() throw (script::BasicErrorException, uno::RuntimeException)
     557                 :            : {
     558                 :            :     // #TODO how are Chart sheets handled ( I know we don't even consider
     559                 :            :     // them in the worksheets/sheets collections ), but.....???
     560                 :            :     // note: in vba for excel the parent of a Chart sheet is a workbook,
     561                 :            :     // e.g. 'ThisWorkbook'
     562         [ #  # ]:          0 :     uno::Reference< XHelperInterface > xParent( getParent() );
     563 [ #  # ][ #  # ]:          0 :     ScVbaChartObject* pChartObj = static_cast< ScVbaChartObject* >( xParent.get() );
     564         [ #  # ]:          0 :     if ( pChartObj )
     565         [ #  # ]:          0 :         pChartObj->Activate();
     566                 :            :     else
     567 [ #  # ][ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no ChartObject as parent" ) ) );
     568                 :          0 : }
     569                 :            : 
     570                 :            : void SAL_CALL
     571                 :          0 : ScVbaChart::setSourceData( const css::uno::Reference< ::ooo::vba::excel::XRange >& _xCalcRange, const css::uno::Any& _aPlotBy ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
     572                 :            : {
     573                 :            :     try
     574                 :            :     {
     575         [ #  # ]:          0 :         uno::Sequence< table::CellRangeAddress > mRangeAddresses(1);
     576                 :          0 :         table::CellRangeAddress mSingleRangeAddress;
     577                 :            : 
     578 [ #  # ][ #  # ]:          0 :         uno::Reference< sheet::XCellRangeAddressable > xAddressable( _xCalcRange->getCellRange(), uno::UNO_QUERY_THROW );
                 [ #  # ]
     579 [ #  # ][ #  # ]:          0 :         mSingleRangeAddress = xAddressable->getRangeAddress();
     580                 :            : 
     581         [ #  # ]:          0 :         mRangeAddresses[0] = mSingleRangeAddress;
     582                 :            : 
     583 [ #  # ][ #  # ]:          0 :         mxTableChart->setRanges(mRangeAddresses);
     584                 :            : 
     585                 :          0 :         sal_Bool bsetRowHeaders = false;
     586                 :          0 :         sal_Bool bsetColumnHeaders = false;
     587                 :            : 
     588 [ #  # ][ #  # ]:          0 :         ScVbaRange* pRange = static_cast< ScVbaRange* >( _xCalcRange.get() );
     589         [ #  # ]:          0 :         if ( pRange )
     590                 :            :         {
     591         [ #  # ]:          0 :             ScDocument* pDoc = pRange->getScDocument();
     592         [ #  # ]:          0 :             if ( pDoc )
     593                 :            :             {
     594         [ #  # ]:          0 :                 bsetRowHeaders = pDoc->HasRowHeader(  static_cast< SCCOL >( mSingleRangeAddress.StartColumn ), static_cast< SCROW >( mSingleRangeAddress.StartRow ), static_cast< SCCOL >( mSingleRangeAddress.EndColumn ), static_cast< SCROW >( mSingleRangeAddress.EndRow ), static_cast< SCTAB >( mSingleRangeAddress.Sheet ) );
     595         [ #  # ]:          0 :                 bsetColumnHeaders =  pDoc->HasColHeader(  static_cast< SCCOL >( mSingleRangeAddress.StartColumn ), static_cast< SCROW >( mSingleRangeAddress.StartRow ), static_cast< SCCOL >( mSingleRangeAddress.EndColumn ), static_cast< SCROW >( mSingleRangeAddress.EndRow ), static_cast< SCTAB >( mSingleRangeAddress.Sheet ));
     596                 :            : ;
     597                 :            :             }
     598                 :            :         }
     599 [ #  # ][ #  # ]:          0 :         mxTableChart->setHasRowHeaders(bsetRowHeaders);
     600 [ #  # ][ #  # ]:          0 :         mxTableChart->setHasColumnHeaders(bsetColumnHeaders);
     601                 :            : 
     602 [ #  # ][ #  # ]:          0 :         if ((!bsetColumnHeaders) || (!bsetRowHeaders))
     603                 :            :         {
     604 [ #  # ][ #  # ]:          0 :             uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
                 [ #  # ]
     605         [ #  # ]:          0 :             if (!bsetColumnHeaders)
     606                 :            :             {
     607 [ #  # ][ #  # ]:          0 :                 xChartDataArray->setColumnDescriptions( getDefaultSeriesDescriptions(xChartDataArray->getColumnDescriptions().getLength() ));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     608                 :            :             }
     609         [ #  # ]:          0 :             if (!bsetRowHeaders)
     610                 :            :             {
     611 [ #  # ][ #  # ]:          0 :                 xChartDataArray->setRowDescriptions(getDefaultSeriesDescriptions(xChartDataArray->getRowDescriptions().getLength() ));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     612                 :          0 :             }
     613                 :            :         }
     614                 :            : 
     615         [ #  # ]:          0 :         if ( _aPlotBy.hasValue() )
     616                 :            :         {
     617                 :          0 :             sal_Int32 nVal = 0;
     618                 :          0 :             _aPlotBy >>= nVal;
     619         [ #  # ]:          0 :             setPlotBy( nVal );
     620                 :            :         }
     621                 :            :         else
     622                 :            :         {
     623                 :          0 :             sal_Int32 nRows =  mSingleRangeAddress.EndRow - mSingleRangeAddress.StartRow;
     624                 :          0 :             sal_Int32 nCols = mSingleRangeAddress.EndColumn - mSingleRangeAddress.StartColumn;
     625                 :            :             // AutoDetect emulation
     626         [ #  # ]:          0 :             if ( nRows > nCols )
     627         [ #  # ]:          0 :                 setPlotBy( xlColumns );
     628         [ #  # ]:          0 :             else if ( nRows <= nCols )
     629         [ #  # ]:          0 :                 setPlotBy( xlRows );
     630         [ #  # ]:          0 :         }
     631                 :            :     }
     632         [ #  # ]:          0 :     catch (const uno::Exception&)
     633                 :            :     {
     634         [ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     635                 :            :     }
     636                 :          0 : }
     637                 :            : 
     638                 :            : uno::Sequence< rtl::OUString >
     639                 :          0 : ScVbaChart::getDefaultSeriesDescriptions( sal_Int32 _nCount )
     640                 :            : {
     641                 :          0 :     uno::Sequence< rtl::OUString > sDescriptions ( _nCount );
     642                 :          0 :     sal_Int32 nLen = sDescriptions.getLength();
     643         [ #  # ]:          0 :     for (sal_Int32 i = 0; i < nLen; i++)
     644                 :            :     {
     645         [ #  # ]:          0 :         sDescriptions[i] = DEFAULTSERIESPREFIX + rtl::OUString::valueOf(i+1);
     646                 :            :     }
     647                 :          0 :     return sDescriptions;
     648                 :            : }
     649                 :            : 
     650                 :            : void
     651                 :          0 : ScVbaChart::setDefaultChartType() throw ( script::BasicErrorException )
     652                 :            : {
     653                 :          0 :     setChartType( xlColumnClustered );
     654                 :          0 : }
     655                 :            : 
     656                 :            : void
     657                 :          0 : ScVbaChart::setPlotBy( ::sal_Int32 _nPlotBy ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
     658                 :            : {
     659                 :            :     try
     660                 :            :     {
     661         [ #  # ]:          0 :         if ( !mxDiagramPropertySet.is() )
     662         [ #  # ]:          0 :             setDefaultChartType();
     663      [ #  #  # ]:          0 :         switch (_nPlotBy)
     664                 :            :         {
     665                 :            :             case xlRows:
     666 [ #  # ][ #  # ]:          0 :                 mxDiagramPropertySet->setPropertyValue( DATAROWSOURCE,  uno::makeAny( chart::ChartDataRowSource_ROWS ) );
                 [ #  # ]
     667                 :          0 :                 break;
     668                 :            :             case xlColumns:
     669 [ #  # ][ #  # ]:          0 :                 mxDiagramPropertySet->setPropertyValue( DATAROWSOURCE, uno::makeAny( chart::ChartDataRowSource_COLUMNS) );
                 [ #  # ]
     670                 :          0 :                 break;
     671                 :            :             default:
     672         [ #  # ]:          0 :                 throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     673                 :            :         }
     674                 :            :     }
     675         [ #  # ]:          0 :     catch (const uno::Exception&)
     676                 :            :     {
     677         [ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     678                 :            :     }
     679                 :          0 : }
     680                 :            : 
     681                 :            : ::sal_Int32 SAL_CALL
     682                 :          0 : ScVbaChart::getPlotBy(  ) throw (script::BasicErrorException, uno::RuntimeException)
     683                 :            : {
     684                 :            :     try
     685                 :            :     {
     686                 :            :         chart::ChartDataRowSource aChartDataRowSource;
     687 [ #  # ][ #  # ]:          0 :         mxDiagramPropertySet->getPropertyValue(DATAROWSOURCE) >>= aChartDataRowSource;
                 [ #  # ]
     688         [ #  # ]:          0 :         if (aChartDataRowSource == chart::ChartDataRowSource_COLUMNS)
     689                 :            :         {
     690                 :          0 :             return xlColumns;
     691                 :            :         }
     692                 :            :         else
     693                 :            :         {
     694                 :          0 :             return xlRows;
     695                 :            :         }
     696                 :            :     }
     697         [ #  # ]:          0 :     catch (const uno::Exception&)
     698                 :            :     {
     699         [ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     700                 :            :     }
     701                 :            : }
     702                 :            : 
     703                 :            : void
     704                 :          0 : ScVbaChart::setDiagram( const rtl::OUString& _sDiagramType ) throw( script::BasicErrorException )
     705                 :            : {
     706                 :            :     try
     707                 :            :     {
     708         [ #  # ]:          0 :         uno::Reference< lang::XMultiServiceFactory > xMSF( mxChartDocument, uno::UNO_QUERY_THROW );
     709 [ #  # ][ #  # ]:          0 :         uno::Reference< chart::XDiagram > xDiagram( xMSF->createInstance( _sDiagramType ), uno::UNO_QUERY_THROW  );
                 [ #  # ]
     710 [ #  # ][ #  # ]:          0 :         mxChartDocument->setDiagram( xDiagram );
     711         [ #  # ]:          0 :         mxDiagramPropertySet.set( xDiagram, uno::UNO_QUERY_THROW );
     712                 :            :     }
     713         [ #  # ]:          0 :     catch ( const uno::Exception& )
     714                 :            :     {
     715         [ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     716                 :            :     }
     717                 :          0 : }
     718                 :            : 
     719                 :            : // #TODO find out why we have Location/getLocation ? there is afaiks no
     720                 :            : // Location property, just a Location function for the Chart object
     721                 :            : sal_Int32 SAL_CALL
     722                 :          0 : ScVbaChart::Location() throw (css::script::BasicErrorException, css::uno::RuntimeException)
     723                 :            : {
     724                 :          0 :     return getLocation();
     725                 :            : }
     726                 :            : 
     727                 :            : sal_Int32 SAL_CALL
     728                 :          0 : ScVbaChart::getLocation() throw (css::script::BasicErrorException, css::uno::RuntimeException)
     729                 :            : {
     730                 :          0 :      return -1;
     731                 :            : }
     732                 :            : 
     733                 :            : void SAL_CALL
     734                 :          0 : ScVbaChart::setLocation( ::sal_Int32 /*where*/, const css::uno::Any& /*Name*/ ) throw (script::BasicErrorException, uno::RuntimeException)
     735                 :            : {
     736                 :            :     // Helper api just stubs out the code <shrug>
     737                 :            :     // #TODO come back and make sense out of this
     738                 :            : //        String sheetName = null;
     739                 :            : //
     740                 :            : //        if ((name != null) && name instanceof String) {
     741                 :            : //            sheetName = (String) name;
     742                 :            : //        }
     743                 :            : //        XSpreadsheetDocument xShDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface( XSpreadsheetDocument.class,getXModel() );
     744                 :            : //        com.sun.star.sheet.XSpreadsheets xSheets = xShDoc.Sheets();
     745                 :            : //
     746                 :            : //        switch (where) {
     747                 :            : //        case ClLocationType.clLocationAsObject_value: //{
     748                 :            : //
     749                 :            : //            if (sheetName == null) {
     750                 :            : //                DebugHelper.writeInfo("Can't embed in Chart without knowing SheetName");
     751                 :            : //                return;
     752                 :            : //            }
     753                 :            : //
     754                 :            : //            try {
     755                 :            : //                Any any = (Any) xSheets.getByName(sheetName);
     756                 :            : //                chartSheet = (XSpreadsheet) any.getObject();
     757                 :            : //
     758                 :            : //                // chartSheet = (XSpreadsheet) xSheets.getByName( sheetName );
     759                 :            : //            } catch (NoSuchElementException e) {
     760                 :            : //                // TODO Auto-generated catch block
     761                 :            : //                e.printStackTrace();
     762                 :            : //
     763                 :            : //                return;
     764                 :            : //            } catch (WrappedTargetException e) {
     765                 :            : //                // TODO Auto-generated catch block
     766                 :            : //                e.printStackTrace();
     767                 :            : //
     768                 :            : //                return;
     769                 :            : //            } catch (java.lang.Exception e) {
     770                 :            : //                e.printStackTrace();
     771                 :            : //            }
     772                 :            : //
     773                 :            : //            XTableChartsSupplier xTCS = (XTableChartsSupplier) UnoRuntime.queryInterface( XTableChartsSupplier.class, chartSheet);
     774                 :            : //            XTableCharts xTableCharts = xTCS.getCharts();
     775                 :            : //            XIndexAccess xIA = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xTableCharts);
     776                 :            : //            int numCharts = xIA.getCount();
     777                 :            : //            chartName = "Chart " + (numCharts + 1);
     778                 :            : //
     779                 :            : //            //}
     780                 :            : //            break;
     781                 :            : //
     782                 :            : //        case ClLocationType.clLocationAsNewSheet_value:
     783                 :            : //        case ClLocationType.clLocationAutomatic_value:default: //{
     784                 :            : //            chartName = "Chart 1"; // Since it's a new sheet, it's the first on it...
     785                 :            : //
     786                 :            : //            XIndexAccess xSheetIA = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xSheets);
     787                 :            : //
     788                 :            : //            short newSheetNum = (short) (xSheetIA.getCount() + 1);
     789                 :            : //
     790                 :            : //            if (sheetName == null){
     791                 :            : //                sheetName = "ChartSheet " + newSheetNum; // Why not?
     792                 :            : //            }
     793                 :            : //            // DPK TODO : Probably should use Sheets to create this!
     794                 :            : //            xSheets.insertNewByName(sheetName, newSheetNum);
     795                 :            : //
     796                 :            : //            try {
     797                 :            : //                chartSheet =
     798                 :            : //                    (XSpreadsheet) xSheets.getByName(sheetName);
     799                 :            : //            } catch (NoSuchElementException e) {
     800                 :            : //                // TODO Auto-generated catch block
     801                 :            : //                e.printStackTrace();
     802                 :            : //
     803                 :            : //                return;
     804                 :            : //            } catch (WrappedTargetException e) {
     805                 :            : //                // TODO Auto-generated catch block
     806                 :            : //                e.printStackTrace();
     807                 :            : //
     808                 :            : //                return;
     809                 :            : //            }
     810                 :            : //
     811                 :            : //            //}
     812                 :            : //            break;
     813                 :            : //        }
     814                 :            : //
     815                 :            : //        // Last thing should be a call to createChartForReal(), one of them
     816                 :            : //        // should succeed.
     817                 :            : //        createChartForReal();
     818                 :            : 
     819                 :          0 : }
     820                 :            : 
     821                 :            : sal_Bool SAL_CALL
     822                 :          0 : ScVbaChart::getHasTitle(  ) throw (script::BasicErrorException, uno::RuntimeException)
     823                 :            : {
     824                 :          0 :     sal_Bool bHasTitle = false;
     825                 :            :     try
     826                 :            :     {
     827 [ #  # ][ #  # ]:          0 :         mxChartPropertySet->getPropertyValue(HASMAINTITLE) >>= bHasTitle;
     828                 :            :     }
     829         [ #  # ]:          0 :     catch (const uno::Exception&)
     830                 :            :     {
     831         [ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     832                 :            :     }
     833                 :          0 :     return bHasTitle;
     834                 :            : }
     835                 :            : 
     836                 :            : void SAL_CALL
     837                 :          0 : ScVbaChart::setHasTitle( ::sal_Bool bTitle ) throw (script::BasicErrorException, uno::RuntimeException)
     838                 :            : {
     839                 :            :     try
     840                 :            :     {
     841 [ #  # ][ #  # ]:          0 :         mxChartPropertySet->setPropertyValue(HASMAINTITLE, uno::makeAny( bTitle ));
                 [ #  # ]
     842                 :            :     }
     843         [ #  # ]:          0 :     catch (const uno::Exception&)
     844                 :            :     {
     845         [ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     846                 :            :     }
     847                 :            : 
     848                 :          0 : }
     849                 :            : 
     850                 :            : ::sal_Bool SAL_CALL
     851                 :          0 : ScVbaChart::getHasLegend(  ) throw (script::BasicErrorException, uno::RuntimeException)
     852                 :            : {
     853                 :          0 :     sal_Bool bHasLegend = false;
     854                 :            :     try
     855                 :            :     {
     856 [ #  # ][ #  # ]:          0 :         mxChartPropertySet->getPropertyValue(HASLEGEND) >>= bHasLegend;
     857                 :            :     }
     858         [ #  # ]:          0 :     catch (const uno::Exception&)
     859                 :            :     {
     860         [ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     861                 :            :     }
     862                 :          0 :     return bHasLegend;
     863                 :            : }
     864                 :            : 
     865                 :            : void SAL_CALL
     866                 :          0 : ScVbaChart::setHasLegend( ::sal_Bool bLegend ) throw (script::BasicErrorException, uno::RuntimeException)
     867                 :            : {
     868                 :            :     try
     869                 :            :     {
     870 [ #  # ][ #  # ]:          0 :         mxChartPropertySet->setPropertyValue(HASLEGEND, uno::makeAny(bLegend));
                 [ #  # ]
     871                 :            :     }
     872         [ #  # ]:          0 :     catch (const uno::Exception&)
     873                 :            :     {
     874         [ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     875                 :            :     }
     876                 :          0 : }
     877                 :            : 
     878                 :            : uno::Reference< excel::XChartTitle > SAL_CALL
     879                 :          0 : ScVbaChart::getChartTitle(  ) throw (script::BasicErrorException, uno::RuntimeException)
     880                 :            : {
     881 [ #  # ][ #  # ]:          0 :     uno::Reference< drawing::XShape > xTitleShape = mxChartDocument->getTitle();
     882                 :            :     // #TODO check parent
     883 [ #  # ][ #  # ]:          0 :     return new ScVbaChartTitle(this, mxContext, xTitleShape);
         [ #  # ][ #  # ]
     884                 :            : }
     885                 :            : 
     886                 :            : uno::Any SAL_CALL
     887                 :          0 : ScVbaChart::Axes( const uno::Any& Type, const uno::Any& AxisGroup ) throw (script::BasicErrorException, uno::RuntimeException)
     888                 :            : {
     889                 :            :     // mmm chart probably is the parent, #TODO check parent
     890 [ #  # ][ #  # ]:          0 :     uno::Reference< excel::XAxes > xAxes = new ScVbaAxes( this, mxContext, this );
         [ #  # ][ #  # ]
                 [ #  # ]
     891         [ #  # ]:          0 :     if ( !Type.hasValue() )
     892         [ #  # ]:          0 :         return uno::makeAny( xAxes );
     893 [ #  # ][ #  # ]:          0 :     return xAxes->Item( Type, AxisGroup );
     894                 :            : }
     895                 :            : bool
     896                 :          0 : ScVbaChart::is3D() throw ( uno::RuntimeException )
     897                 :            : {
     898                 :            :     // #TODO perhaps provide limited Debughelper functionality
     899                 :          0 :     sal_Bool is3d = false;
     900 [ #  # ][ #  # ]:          0 :     mxDiagramPropertySet->getPropertyValue(DIM3D) >>= is3d;
     901                 :          0 :     return is3d;
     902                 :            : }
     903                 :            : 
     904                 :            : sal_Int32
     905                 :          0 : ScVbaChart::getStackedType( sal_Int32 _nStacked, sal_Int32 _n100PercentStacked, sal_Int32 _nUnStacked ) throw ( uno::RuntimeException )
     906                 :            : {
     907                 :            :     // #TODO perhaps provide limited Debughelper functionality
     908         [ #  # ]:          0 :     if (isStacked())
     909                 :            :     {
     910         [ #  # ]:          0 :         if (is100PercentStacked())
     911                 :          0 :             return _n100PercentStacked;
     912                 :            :         else
     913                 :          0 :             return _nStacked;
     914                 :            :     }
     915                 :            :     else
     916                 :          0 :         return _nUnStacked;
     917                 :            : }
     918                 :            : 
     919                 :            : bool
     920                 :          0 : ScVbaChart::isStacked() throw ( uno::RuntimeException )
     921                 :            : {
     922                 :            :     // #TODO perhaps provide limited Debughelper functionality
     923                 :          0 :     sal_Bool bStacked = false;
     924 [ #  # ][ #  # ]:          0 :     mxDiagramPropertySet->getPropertyValue(STACKED) >>= bStacked;
     925                 :          0 :     return bStacked;
     926                 :            : }
     927                 :            : 
     928                 :            : bool
     929                 :          0 : ScVbaChart::is100PercentStacked() throw ( uno::RuntimeException )
     930                 :            : {
     931                 :            :     // #TODO perhaps provide limited Debughelper functionality
     932                 :          0 :     sal_Bool b100Percent = false;
     933 [ #  # ][ #  # ]:          0 :     mxDiagramPropertySet->getPropertyValue(PERCENT) >>= b100Percent;
     934                 :          0 :     return b100Percent;
     935                 :            : }
     936                 :            : 
     937                 :            : sal_Int32
     938                 :          0 : ScVbaChart::getSolidType(sal_Int32 _nDeep, sal_Int32 _nVertiStacked, sal_Int32 _nVerti100PercentStacked, sal_Int32 _nVertiUnStacked, sal_Int32 _nHoriStacked, sal_Int32 _nHori100PercentStacked, sal_Int32 _nHoriUnStacked) throw ( script::BasicErrorException )
     939                 :            : {
     940                 :          0 :     sal_Bool bIsVertical = true;
     941                 :            :     try
     942                 :            :     {
     943 [ #  # ][ #  # ]:          0 :         mxDiagramPropertySet->getPropertyValue(VERTICAL) >>= bIsVertical;
     944                 :          0 :         sal_Bool bIsDeep = false;
     945 [ #  # ][ #  # ]:          0 :         mxDiagramPropertySet->getPropertyValue(DEEP) >>= bIsDeep;
     946                 :            : 
     947         [ #  # ]:          0 :         if (bIsDeep)
     948                 :            :         {
     949                 :          0 :             return _nDeep;
     950                 :            :         }
     951                 :            :         else
     952                 :            :         {
     953         [ #  # ]:          0 :             if (bIsVertical)
     954                 :            :             {
     955         [ #  # ]:          0 :                 return getStackedType(_nVertiStacked, _nVerti100PercentStacked, _nVertiUnStacked);
     956                 :            :             }
     957                 :            :             else
     958                 :            :             {
     959         [ #  # ]:          0 :                 return getStackedType(_nHoriStacked, _nHori100PercentStacked, _nHoriUnStacked);
     960                 :            :             }
     961                 :            :         }
     962                 :            :     }
     963         [ #  # ]:          0 :     catch (const uno::Exception&)
     964                 :            :     {
     965         [ #  # ]:          0 :         throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     966                 :            :     }
     967                 :            : }
     968                 :            : 
     969                 :            : 
     970                 :            : sal_Int32
     971                 :          0 : ScVbaChart::getStockUpDownValue(sal_Int32 _nUpDown, sal_Int32 _nNotUpDown) throw (script::BasicErrorException)
     972                 :            : {
     973                 :          0 :     sal_Bool bUpDown = false;
     974                 :            :     try
     975                 :            :     {
     976 [ #  # ][ #  # ]:          0 :         mxDiagramPropertySet->getPropertyValue(UPDOWN) >>= bUpDown;
     977         [ #  # ]:          0 :         if (bUpDown)
     978                 :            :         {
     979                 :          0 :             return _nUpDown;
     980                 :            :         }
     981                 :            :         else
     982                 :            :         {
     983                 :          0 :             return _nNotUpDown;
     984                 :            :         }
     985                 :            :     }
     986   [ #  #  #  # ]:          0 :     catch (const uno::Exception&)
     987                 :            :     {
     988                 :          0 :         rtl::OUString aTemp;    // temporary needed for g++ 3.3.5
     989   [ #  #  #  # ]:          0 :         script::BasicErrorException( aTemp, uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
     990                 :            :     }
     991                 :          0 :     return _nNotUpDown;
     992                 :            : }
     993                 :            : 
     994                 :            : bool
     995                 :          0 : ScVbaChart::hasMarkers() throw ( script::BasicErrorException )
     996                 :            : {
     997                 :          0 :     bool bHasMarkers = false;
     998                 :            :     try
     999                 :            :     {
    1000                 :          0 :         sal_Int32 nSymbol=0;
    1001 [ #  # ][ #  # ]:          0 :         mxDiagramPropertySet->getPropertyValue(SYMBOLTYPE) >>= nSymbol;
    1002                 :          0 :         bHasMarkers = nSymbol != chart::ChartSymbolType::NONE;
    1003                 :            :     }
    1004         [ #  # ]:          0 :     catch (const uno::Exception&)
    1005                 :            :     {
    1006                 :          0 :         rtl::OUString aTemp;    // temporary needed for g++ 3.3.5
    1007   [ #  #  #  # ]:          0 :         script::BasicErrorException( aTemp, uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
    1008                 :            :     }
    1009                 :          0 :     return bHasMarkers;
    1010                 :            : }
    1011                 :            : 
    1012                 :            : sal_Int32
    1013                 :          0 : ScVbaChart::getMarkerType(sal_Int32 _nWithMarkers, sal_Int32 _nWithoutMarkers) throw ( script::BasicErrorException )
    1014                 :            : {
    1015         [ #  # ]:          0 :     if (hasMarkers())
    1016                 :          0 :         return _nWithMarkers;
    1017                 :          0 :     return _nWithoutMarkers;
    1018                 :            : }
    1019                 :            : 
    1020                 :            : void
    1021                 :          0 : ScVbaChart::assignDiagramAttributes()
    1022                 :            : {
    1023                 :          0 :     xAxisXSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
    1024                 :          0 :     xAxisYSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
    1025                 :          0 :     xAxisZSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
    1026                 :          0 :     xTwoAxisXSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
    1027                 :          0 :     xTwoAxisYSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
    1028                 :          0 : }
    1029                 :            : 
    1030                 :            : 
    1031                 :            : uno::Reference< beans::XPropertySet >
    1032                 :          0 : ScVbaChart::getAxisPropertySet(sal_Int32 _nAxisType, sal_Int32 _nAxisGroup) throw ( script::BasicErrorException )
    1033                 :            : {
    1034                 :          0 :     assignDiagramAttributes();
    1035                 :          0 :     uno::Reference< beans::XPropertySet > xAxisProps;
    1036   [ #  #  #  # ]:          0 :     switch(_nAxisType)
    1037                 :            :     {
    1038                 :            :         case xlCategory:
    1039         [ #  # ]:          0 :             if (_nAxisGroup == xlPrimary)
    1040                 :            :             {
    1041 [ #  # ][ #  # ]:          0 :                 xAxisProps = xAxisXSupplier->getXAxis();
                 [ #  # ]
    1042                 :            :             }
    1043         [ #  # ]:          0 :             else if (_nAxisGroup == xlSecondary)
    1044                 :            :             {
    1045 [ #  # ][ #  # ]:          0 :                 xAxisProps = xTwoAxisXSupplier->getSecondaryXAxis();
                 [ #  # ]
    1046                 :            :             }
    1047                 :          0 :             break;
    1048                 :            :         case xlSeriesAxis:
    1049 [ #  # ][ #  # ]:          0 :             xAxisProps = xAxisZSupplier->getZAxis();
                 [ #  # ]
    1050                 :          0 :             break;
    1051                 :            :         case xlValue:
    1052         [ #  # ]:          0 :             if (_nAxisGroup == xlPrimary)
    1053 [ #  # ][ #  # ]:          0 :                 xAxisProps = xAxisYSupplier->getYAxis();
                 [ #  # ]
    1054         [ #  # ]:          0 :             else if (_nAxisGroup == xlSecondary)
    1055 [ #  # ][ #  # ]:          0 :                 xAxisProps = xTwoAxisYSupplier->getSecondaryYAxis();
                 [ #  # ]
    1056                 :          0 :             break;
    1057                 :            :         default:
    1058                 :          0 :             return xAxisProps;
    1059                 :            :         }
    1060                 :          0 :     return xAxisProps;
    1061                 :            : }
    1062                 :            : 
    1063                 :            : 
    1064                 :            : rtl::OUString
    1065                 :          0 : ScVbaChart::getServiceImplName()
    1066                 :            : {
    1067                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaChart"));
    1068                 :            : }
    1069                 :            : 
    1070                 :            : uno::Sequence< rtl::OUString >
    1071                 :          0 : ScVbaChart::getServiceNames()
    1072                 :            : {
    1073 [ #  # ][ #  # ]:          0 :     static uno::Sequence< rtl::OUString > aServiceNames;
         [ #  # ][ #  # ]
    1074         [ #  # ]:          0 :     if ( aServiceNames.getLength() == 0 )
    1075                 :            :     {
    1076                 :          0 :         aServiceNames.realloc( 1 );
    1077         [ #  # ]:          0 :         aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Chart" ) );
    1078                 :            :     }
    1079                 :          0 :     return aServiceNames;
    1080 [ +  - ][ +  - ]:          9 : }
    1081                 :            : 
    1082                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10