LCOV - code coverage report
Current view: top level - sc/source/filter/xml - datastreamimport.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 39 2.6 %
Date: 2014-11-03 Functions: 2 6 33.3 %
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 "datastreamimport.hxx"
      11             : #include "xmlimprt.hxx"
      12             : 
      13             : #include <rangeutl.hxx>
      14             : #include <importfilterdata.hxx>
      15             : #include <xmloff/nmspmap.hxx>
      16             : #include <xmloff/xmltoken.hxx>
      17             : #include <formula/grammar.hxx>
      18             : 
      19             : using namespace com::sun::star;
      20             : using namespace xmloff::token;
      21             : 
      22           0 : ScXMLDataStreamContext::ScXMLDataStreamContext(
      23             :     ScXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
      24             :     const com::sun::star::uno::Reference<
      25             :         com::sun::star::xml::sax::XAttributeList>& xAttrList ) :
      26             :     ScXMLImportContext(rImport, nPrefix, rLocalName),
      27             :     mbRefreshOnEmpty(false),
      28           0 :     meInsertPos(sc::ImportPostProcessData::DataStream::InsertBottom)
      29             : {
      30           0 :     if (!xAttrList.is())
      31           0 :         return;
      32             : 
      33           0 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetDataStreamAttrTokenMap();
      34             : 
      35           0 :     for (sal_Int32 i = 0; i < xAttrList->getLength(); ++i)
      36             :     {
      37           0 :         const OUString& rName = xAttrList->getNameByIndex(i);
      38           0 :         OUString aLocalName;
      39             :         sal_uInt16 nLocalPrefix =
      40           0 :             GetScImport().GetNamespaceMap().GetKeyByAttrName(rName, &aLocalName);
      41             : 
      42           0 :         const OUString& rVal = xAttrList->getValueByIndex(i);
      43           0 :         switch (rAttrTokenMap.Get(nLocalPrefix, aLocalName))
      44             :         {
      45             :             case XML_TOK_DATA_STREAM_ATTR_URL:
      46           0 :                 maURL = GetScImport().GetAbsoluteReference(rVal);
      47           0 :             break;
      48             :             case XML_TOK_DATA_STREAM_ATTR_RANGE:
      49             :             {
      50           0 :                 ScDocument* pDoc = GetScImport().GetDocument();
      51           0 :                 sal_Int32 nOffset = 0;
      52           0 :                 if (!ScRangeStringConverter::GetRangeFromString(
      53           0 :                     maRange, rVal, pDoc, formula::FormulaGrammar::CONV_OOO, nOffset))
      54           0 :                     maRange.SetInvalid();
      55             :             }
      56           0 :             break;
      57             :             case XML_TOK_DATA_STREAM_ATTR_EMPTY_LINE_REFRESH:
      58           0 :                 mbRefreshOnEmpty = IsXMLToken(rVal, XML_TRUE);
      59           0 :             break;
      60             :             case XML_TOK_DATA_STREAM_ATTR_INSERTION_POSITION:
      61           0 :                 meInsertPos = IsXMLToken(rVal, XML_TOP) ?
      62             :                     sc::ImportPostProcessData::DataStream::InsertTop :
      63           0 :                     sc::ImportPostProcessData::DataStream::InsertBottom;
      64           0 :             break;
      65             :             default:
      66             :                 ;
      67             :         }
      68           0 :     }
      69             : }
      70             : 
      71           0 : ScXMLDataStreamContext::~ScXMLDataStreamContext() {}
      72             : 
      73           0 : void ScXMLDataStreamContext::EndElement()
      74             : {
      75           0 :     if (!maRange.IsValid())
      76             :         // Range must be valid.
      77           0 :         return;
      78             : 
      79           0 :     sc::ImportPostProcessData* pData = GetScImport().GetPostProcessData();
      80           0 :     if (!pData)
      81           0 :         return;
      82             : 
      83           0 :     pData->mpDataStream.reset(new sc::ImportPostProcessData::DataStream);
      84           0 :     sc::ImportPostProcessData::DataStream& rData = *pData->mpDataStream;
      85             : 
      86           0 :     rData.maURL = maURL;
      87           0 :     rData.maRange = maRange;
      88           0 :     rData.mbRefreshOnEmpty = mbRefreshOnEmpty;
      89           0 :     rData.meInsertPos = meInsertPos;
      90         228 : }
      91             : 
      92             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10