LCOV - code coverage report
Current view: top level - oox/source/drawingml/chart - datasourceconverter.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 40 41 97.6 %
Date: 2015-06-13 12:38:46 Functions: 8 10 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "drawingml/chart/datasourceconverter.hxx"
      21             : 
      22             : #include <com/sun/star/chart2/XChartDocument.hpp>
      23             : #include "oox/drawingml/chart/chartconverter.hxx"
      24             : #include "oox/drawingml/chart/datasourcemodel.hxx"
      25             : #include "oox/token/properties.hxx"
      26             : 
      27             : namespace oox {
      28             : namespace drawingml {
      29             : namespace chart {
      30             : 
      31             : using namespace ::com::sun::star::chart2::data;
      32             : using namespace ::com::sun::star::uno;
      33             : 
      34         847 : DataSequenceConverter::DataSequenceConverter( const ConverterRoot& rParent, DataSequenceModel& rModel ) :
      35         847 :     ConverterBase< DataSequenceModel >( rParent, rModel )
      36             : {
      37         847 : }
      38             : 
      39         847 : DataSequenceConverter::~DataSequenceConverter()
      40             : {
      41         847 : }
      42             : 
      43         847 : Reference< XDataSequence > DataSequenceConverter::createDataSequence( const OUString& rRole )
      44             : {
      45             :     // create data sequence from data source model (virtual call at chart converter)
      46         847 :     Reference< XDataSequence > xDataSeq;
      47         847 :     if( getChartConverter() )
      48             :     {
      49             :         // the internal data table does not support complex labels
      50             :         // this is only supported in Calc!!!
      51             :         // merge the labels into a single one
      52         847 :         if(rRole == "label")
      53             :         {
      54         316 :             mrModel.mnPointCount = std::min<sal_Int32>(mrModel.mnPointCount, 1);
      55         316 :             OUStringBuffer aTitle;
      56         316 :             bool bFirst = true;
      57         946 :             for(DataSequenceModel::AnyMap::const_iterator itr = mrModel.maData.begin(),
      58         316 :                     itrEnd = mrModel.maData.end(); itr != itrEnd; ++itr)
      59             :             {
      60         314 :                 Any aAny = itr->second;
      61         314 :                 if(aAny.has<OUString>())
      62             :                 {
      63         314 :                     if(!bFirst)
      64           0 :                         aTitle.append(" ");
      65             : 
      66         314 :                     aTitle.append(aAny.get<OUString>());
      67         314 :                     bFirst = false;
      68             :                 }
      69         314 :             }
      70             : 
      71         316 :             if(!bFirst)
      72             :             {
      73         314 :                 mrModel.maData.clear();
      74         314 :                 mrModel.maData.insert(std::make_pair<sal_Int32, Any>(1, Any(aTitle.makeStringAndClear())));
      75         316 :             }
      76             :         }
      77         847 :         xDataSeq = getChartConverter()->createDataSequence(getChartDocument()->getDataProvider(), mrModel, rRole);
      78             : 
      79             :         // set sequence role
      80         847 :         PropertySet aSeqProp( xDataSeq );
      81         847 :         aSeqProp.setProperty( PROP_Role, rRole );
      82             :     }
      83         847 :     return xDataSeq;
      84             : }
      85             : 
      86         531 : DataSourceConverter::DataSourceConverter( const ConverterRoot& rParent, DataSourceModel& rModel ) :
      87         531 :     ConverterBase< DataSourceModel >( rParent, rModel )
      88             : {
      89         531 : }
      90             : 
      91         531 : DataSourceConverter::~DataSourceConverter()
      92             : {
      93         531 : }
      94             : 
      95         531 : Reference< XDataSequence > DataSourceConverter::createDataSequence( const OUString& rRole )
      96             : {
      97         531 :     Reference< XDataSequence > xDataSeq;
      98         531 :     if( mrModel.mxDataSeq.is() )
      99             :     {
     100         531 :         DataSequenceConverter aDataSeqConv( *this, *mrModel.mxDataSeq );
     101         531 :         xDataSeq = aDataSeqConv.createDataSequence( rRole );
     102             :     }
     103         531 :     return xDataSeq;
     104             : }
     105             : 
     106             : } // namespace chart
     107             : } // namespace drawingml
     108         246 : } // namespace oox
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11