LCOV - code coverage report
Current view: top level - xmloff/source/chart - SchXMLPropertyMappingContext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 45 0.0 %
Date: 2014-11-03 Functions: 0 5 0.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             : 
      10             : #include "SchXMLPropertyMappingContext.hxx"
      11             : #include "PropertyMap.hxx"
      12             : #include "SchXMLTools.hxx"
      13             : #include <xmloff/xmlnmspe.hxx>
      14             : #include <xmloff/xmlimp.hxx>
      15             : #include <xmloff/nmspmap.hxx>
      16             : #include <xmloff/SchXMLSeriesHelper.hxx>
      17             : #include "SchXMLImport.hxx"
      18             : 
      19             : #include <com/sun/star/chart2/data/XLabeledDataSequence2.hpp>
      20             : #include <com/sun/star/chart2/data/XDataSource.hpp>
      21             : #include <com/sun/star/chart2/data/XDataSink.hpp>
      22             : 
      23             : using namespace com::sun::star;
      24             : using namespace com::sun::star::uno;
      25             : 
      26             : namespace {
      27             : 
      28           0 : Reference< chart2::data::XLabeledDataSequence2 > createAndAddSequenceToSeries( const OUString& rRole
      29             :         , const OUString& rRange
      30             :         , const Reference< chart2::XChartDocument >& xChartDoc
      31             :         , const Reference< chart2::XDataSeries >& xSeries )
      32             : {
      33           0 :     Reference< chart2::data::XLabeledDataSequence2 > xLabeledSeq;
      34             : 
      35           0 :     Reference< chart2::data::XDataSource > xSeriesSource( xSeries,uno::UNO_QUERY );
      36             : 
      37           0 :     if( !(!rRange.isEmpty() && xChartDoc.is() && xSeriesSource.is()) )
      38           0 :         return xLabeledSeq;
      39             : 
      40             :     // create a new sequence
      41           0 :     xLabeledSeq = SchXMLTools::GetNewLabeledDataSequence();
      42             : 
      43             :     // set values at the new sequence
      44           0 :     Reference< chart2::data::XDataSequence > xSeq = SchXMLTools::CreateDataSequence( rRange, xChartDoc );
      45           0 :     Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
      46           0 :     if( xSeqProp.is())
      47           0 :         xSeqProp->setPropertyValue("Role", uno::makeAny( rRole));
      48           0 :     xLabeledSeq->setValues( xSeq );
      49             : 
      50           0 :     Reference< chart2::data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY );
      51           0 :     if( xSink.is())
      52             :     {
      53           0 :         Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xSeriesSource->getDataSequences());
      54           0 :         aData.realloc( aData.getLength() + 1 );
      55           0 :         aData[ aData.getLength() - 1 ] = xLabeledSeq;
      56           0 :         xSink->setData( aData );
      57             :     }
      58             : 
      59           0 :     return xLabeledSeq;
      60             : }
      61             : 
      62             : }
      63             : 
      64           0 : SchXMLPropertyMappingContext::SchXMLPropertyMappingContext( SchXMLImportHelper& rImpHelper,
      65             :         SvXMLImport& rImport, const OUString& rLocalName,
      66             :         tSchXMLLSequencesPerIndex & rLSequencesPerIndex,
      67             :         uno::Reference<
      68             :         chart2::XDataSeries > xSeries ):
      69             :     SvXMLImportContext( rImport, XML_NAMESPACE_LO_EXT, rLocalName ),
      70             :     mrImportHelper( rImpHelper ),
      71             :     mxDataSeries(xSeries),
      72           0 :     mrLSequencesPerIndex(rLSequencesPerIndex)
      73             : {
      74             : 
      75           0 : }
      76             : 
      77           0 : SchXMLPropertyMappingContext::~SchXMLPropertyMappingContext()
      78             : {
      79           0 : }
      80             : 
      81           0 : void SchXMLPropertyMappingContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList )
      82             : {
      83           0 :     OUString aRange;
      84           0 :     OUString aRole;
      85             :     // parse attributes
      86           0 :     sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
      87           0 :     const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetPropMappingAttrTokenMap();
      88             : 
      89           0 :     for( sal_Int16 i = 0; i < nAttrCount; i++ )
      90             :     {
      91           0 :         OUString sAttrName = xAttrList->getNameByIndex( i );
      92           0 :         OUString aLocalName;
      93           0 :         OUString aValue = xAttrList->getValueByIndex( i );
      94           0 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
      95             : 
      96           0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
      97             :         {
      98             :             case XML_TOK_PROPERTY_MAPPING_PROPERTY:
      99           0 :                 aRole = aValue;
     100           0 :                 break;
     101             :             case XML_TOK_PROPERTY_MAPPING_RANGE:
     102           0 :                 aRange = aValue;
     103           0 :                 break;
     104             :         }
     105           0 :     }
     106             : 
     107           0 :     if( !aRange.isEmpty() && !aRole.isEmpty() )
     108             :     {
     109           0 :         Reference< chart2::XChartDocument > xChartDoc( GetImport().GetModel(), uno::UNO_QUERY );
     110             :         Reference< chart2::data::XLabeledDataSequence2 > xSeq =
     111           0 :             createAndAddSequenceToSeries(aRole, aRange, xChartDoc, mxDataSeries);
     112             :         mrLSequencesPerIndex.insert(
     113             :                 tSchXMLLSequencesPerIndex::value_type(
     114             :                     tSchXMLIndexWithPart( 0, SCH_XML_PART_VALUES),
     115           0 :                     Reference< chart2::data::XLabeledDataSequence >( xSeq, UNO_QUERY )));
     116           0 :     }
     117           0 : }
     118             : 
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10