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

Generated by: LCOV version 1.10