LCOV - code coverage report
Current view: top level - reportdesign/source/filter/xml - xmlFunction.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 41 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             :  * 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             : #include "xmlFunction.hxx"
      20             : #include "xmlfilter.hxx"
      21             : #include <xmloff/xmltoken.hxx>
      22             : #include <xmloff/xmlnmspe.hxx>
      23             : #include <xmloff/nmspmap.hxx>
      24             : #include "xmlHelper.hxx"
      25             : #include "xmlEnums.hxx"
      26             : #include "xmlstrings.hrc"
      27             : #include <tools/debug.hxx>
      28             : 
      29             : namespace rptxml
      30             : {
      31             :     using namespace ::com::sun::star;
      32             :     using namespace ::com::sun::star::uno;
      33             :     using namespace ::com::sun::star::report;
      34             :     using namespace ::com::sun::star::xml::sax;
      35             : 
      36             : 
      37           0 : OXMLFunction::OXMLFunction( ORptFilter& _rImport
      38             :                 ,sal_uInt16 nPrfx
      39             :                 ,const OUString& _sLocalName
      40             :                 ,const Reference< XAttributeList > & _xAttrList
      41             :                 ,const Reference< XFunctionsSupplier >& _xFunctions
      42             :                 ,bool _bAddToReport
      43             :                 ) :
      44             :     SvXMLImportContext( _rImport, nPrfx, _sLocalName )
      45           0 :     ,m_xFunctions(_xFunctions->getFunctions())
      46           0 :     ,m_bAddToReport(_bAddToReport)
      47             : {
      48             : 
      49             :     OSL_ENSURE(m_xFunctions.is(),"Functions is NULL!");
      50           0 :     m_xFunction = m_xFunctions->createFunction();
      51             : 
      52             :     OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
      53             : 
      54           0 :     const SvXMLNamespaceMap& rMap = _rImport.GetNamespaceMap();
      55           0 :     const SvXMLTokenMap& rTokenMap = _rImport.GetFunctionElemTokenMap();
      56             : 
      57           0 :     const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
      58           0 :     static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
      59           0 :     for(sal_Int16 i = 0; i < nLength; ++i)
      60             :     {
      61           0 :      OUString sLocalName;
      62           0 :         const OUString sAttrName = _xAttrList->getNameByIndex( i );
      63           0 :         const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
      64           0 :         const OUString sValue = _xAttrList->getValueByIndex( i );
      65             : 
      66             :         try
      67             :         {
      68           0 :             switch( rTokenMap.Get( nPrefix, sLocalName ) )
      69             :             {
      70             :                 case XML_TOK_FUNCTION_NAME:
      71           0 :                     m_xFunction->setName(sValue);
      72           0 :                     break;
      73             :                 case XML_TOK_FUNCTION_FORMULA:
      74           0 :                     m_xFunction->setFormula(ORptFilter::convertFormula(sValue));
      75           0 :                     break;
      76             :                 case XML_TOK_PRE_EVALUATED:
      77           0 :                     m_xFunction->setPreEvaluated(sValue == s_sTRUE);
      78           0 :                     break;
      79             :                 case XML_TOK_INITIAL_FORMULA:
      80           0 :                     if ( !sValue.isEmpty() )
      81           0 :                         m_xFunction->setInitialFormula(beans::Optional< OUString>(sal_True,ORptFilter::convertFormula(sValue)));
      82           0 :                     break;
      83             :                 case XML_TOK_DEEP_TRAVERSING:
      84           0 :                     m_xFunction->setDeepTraversing(sValue == s_sTRUE);
      85           0 :                     break;
      86             :                 default:
      87           0 :                     break;
      88             :             }
      89             :         }
      90           0 :         catch(const Exception&)
      91             :         {
      92             :             OSL_FAIL("Exception catched while putting Function props!");
      93             :         }
      94           0 :     }
      95           0 : }
      96             : 
      97             : 
      98           0 : OXMLFunction::~OXMLFunction()
      99             : {
     100           0 : }
     101             : 
     102           0 : ORptFilter& OXMLFunction::GetOwnImport()
     103             : {
     104           0 :     return static_cast<ORptFilter&>(GetImport());
     105             : }
     106             : 
     107           0 : void OXMLFunction::EndElement()
     108             : {
     109           0 :     if ( m_bAddToReport )
     110             :     {
     111           0 :         GetOwnImport().insertFunction(m_xFunction);
     112           0 :         m_xFunction.clear();
     113             :     }
     114             :     else
     115             :     {
     116             :         try
     117             :         {
     118           0 :             m_xFunctions->insertByIndex(m_xFunctions->getCount(),uno::makeAny(m_xFunction));
     119           0 :             m_xFunction.clear();
     120           0 :         }catch(uno::Exception&)
     121             :         {
     122             :             OSL_FAIL("Exception catched!");
     123             :         }
     124             :     }
     125           0 : }
     126             : 
     127             : 
     128             : } // namespace rptxml
     129             : 
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10