LCOV - code coverage report
Current view: top level - reportdesign/source/filter/xml - xmlReport.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 96 0.0 %
Date: 2014-11-03 Functions: 0 7 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 "xmlReport.hxx"
      20             : #include "xmlfilter.hxx"
      21             : #include <xmloff/xmltoken.hxx>
      22             : #include <xmloff/xmlnmspe.hxx>
      23             : #include <xmloff/nmspmap.hxx>
      24             : #include <xmloff/xmluconv.hxx>
      25             : #include "xmlHelper.hxx"
      26             : #include "xmlGroup.hxx"
      27             : #include "xmlSection.hxx"
      28             : #include "xmlEnums.hxx"
      29             : #include "xmlFunction.hxx"
      30             : #include <tools/diagnose_ex.h>
      31             : #include <com/sun/star/sdb/CommandType.hpp>
      32             : #include "xmlMasterFields.hxx"
      33             : 
      34             : namespace rptxml
      35             : {
      36             :     using namespace ::com::sun::star;
      37             :     using namespace uno;
      38             :     using namespace xml::sax;
      39             : 
      40             : 
      41           0 : OXMLReport::OXMLReport( ORptFilter& rImport,
      42             :                 sal_uInt16 nPrfx, const OUString& rLName,
      43             :                 const Reference< XAttributeList > & _xAttrList
      44             :                 ,const uno::Reference< report::XReportDefinition >& _xComponent
      45             :                 ,OXMLTable* _pContainer) :
      46           0 :     OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer)
      47           0 :     ,m_xComponent(_xComponent)
      48             : {
      49             :     OSL_ENSURE(m_xComponent.is(),"No Report definition!");
      50             : 
      51           0 :     impl_initRuntimeDefaults();
      52             : 
      53           0 :     const SvXMLNamespaceMap& rMap = m_rImport.GetNamespaceMap();
      54           0 :     const SvXMLTokenMap& rTokenMap = m_rImport.GetReportElemTokenMap();
      55             : 
      56           0 :     const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
      57           0 :     static const OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
      58             :     try
      59             :     {
      60           0 :         for(sal_Int16 i = 0; i < nLength; ++i)
      61             :         {
      62           0 :          OUString sLocalName;
      63           0 :             const OUString sAttrName = _xAttrList->getNameByIndex( i );
      64           0 :             const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
      65           0 :             const OUString sValue = _xAttrList->getValueByIndex( i );
      66             : 
      67           0 :             switch( rTokenMap.Get( nPrefix, sLocalName ) )
      68             :             {
      69             :                 case XML_TOK_COMMAND_TYPE:
      70             :                     {
      71           0 :                         sal_uInt16 nRet = static_cast<sal_uInt16>(sdb::CommandType::COMMAND);
      72           0 :                         const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetCommandTypeOptions();
      73           0 :                         SvXMLUnitConverter::convertEnum( nRet, sValue, aXML_EnumMap );
      74           0 :                         m_xComponent->setCommandType(nRet);
      75             :                     }
      76           0 :                     break;
      77             :                 case XML_TOK_COMMAND:
      78           0 :                     m_xComponent->setCommand(sValue);
      79           0 :                     break;
      80             :                 case XML_TOK_FILTER:
      81           0 :                     m_xComponent->setFilter(sValue);
      82           0 :                     break;
      83             :                 case XML_TOK_CAPTION:
      84           0 :                     m_xComponent->setCaption(sValue);
      85           0 :                     break;
      86             :                 case XML_TOK_ESCAPE_PROCESSING:
      87           0 :                     m_xComponent->setEscapeProcessing(sValue == s_sTRUE);
      88           0 :                     break;
      89             :                 case XML_TOK_REPORT_MIMETYPE:
      90           0 :                     m_xComponent->setMimeType(sValue);
      91           0 :                     break;
      92             :                 case XML_TOK_REPORT_NAME:
      93           0 :                     m_xComponent->setName(sValue);
      94           0 :                     break;
      95             :                 default:
      96           0 :                     break;
      97             :             }
      98           0 :         }
      99             :     }
     100           0 :     catch(Exception&)
     101             :     {
     102             :         OSL_FAIL("Exception catched while filling the report definition props");
     103             :     }
     104           0 : }
     105             : 
     106             : 
     107           0 : OXMLReport::~OXMLReport()
     108             : {
     109           0 : }
     110             : 
     111             : 
     112             : 
     113           0 : void OXMLReport::impl_initRuntimeDefaults() const
     114             : {
     115             :     OSL_PRECOND( m_xComponent.is(), "OXMLReport::impl_initRuntimeDefaults: no component!" );
     116           0 :     if ( !m_xComponent.is() )
     117           0 :         return;
     118             : 
     119             :     try
     120             :     {
     121           0 :         m_xComponent->setCommandType( sdb::CommandType::COMMAND );
     122             :     }
     123           0 :     catch( const Exception& )
     124             :     {
     125             :         DBG_UNHANDLED_EXCEPTION();
     126             :     }
     127             : }
     128             : 
     129             : 
     130             : 
     131           0 : SvXMLImportContext* OXMLReport::CreateChildContext(
     132             :         sal_uInt16 nPrefix,
     133             :         const OUString& rLocalName,
     134             :         const Reference< XAttributeList > & xAttrList )
     135             : {
     136           0 :     SvXMLImportContext *pContext = _CreateChildContext(nPrefix,rLocalName,xAttrList);
     137           0 :     if ( pContext )
     138           0 :         return pContext;
     139           0 :     const SvXMLTokenMap&    rTokenMap   = m_rImport.GetReportElemTokenMap();
     140             : 
     141           0 :     switch( rTokenMap.Get( nPrefix, rLocalName ) )
     142             :     {
     143             :         case XML_TOK_REPORT_FUNCTION:
     144             :             {
     145           0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     146           0 :                 pContext = new OXMLFunction( m_rImport, nPrefix, rLocalName,xAttrList,m_xComponent.get(),true);
     147             :             }
     148           0 :             break;
     149             :         case XML_TOK_MASTER_DETAIL_FIELDS:
     150           0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     151           0 :                 pContext = new OXMLMasterFields(m_rImport, nPrefix, rLocalName,xAttrList ,this);
     152           0 :             break;
     153             :         case XML_TOK_REPORT_HEADER:
     154             :             {
     155           0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     156           0 :                 m_xComponent->setReportHeaderOn(sal_True);
     157           0 :                 pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getReportHeader());
     158             :             }
     159           0 :             break;
     160             :         case XML_TOK_PAGE_HEADER:
     161             :             {
     162           0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     163           0 :                 m_xComponent->setPageHeaderOn(sal_True);
     164           0 :                 pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getPageHeader());
     165             :             }
     166           0 :             break;
     167             :         case XML_TOK_GROUP:
     168           0 :             m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     169           0 :             pContext = new OXMLGroup( m_rImport, nPrefix, rLocalName,xAttrList);
     170           0 :             break;
     171             :         case XML_TOK_DETAIL:
     172             :             {
     173           0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     174           0 :                 pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getDetail());
     175             :             }
     176           0 :             break;
     177             :         case XML_TOK_PAGE_FOOTER:
     178             :             {
     179           0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     180           0 :                 m_xComponent->setPageFooterOn(sal_True);
     181           0 :                 pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getPageFooter(),false);
     182             :             }
     183           0 :             break;
     184             :         case XML_TOK_REPORT_FOOTER:
     185             :             {
     186           0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     187           0 :                 m_xComponent->setReportFooterOn(sal_True);
     188           0 :                 pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getReportFooter());
     189             :             }
     190           0 :             break;
     191             :         default:
     192           0 :             break;
     193             :     }
     194             : 
     195           0 :     if( !pContext )
     196           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     197             : 
     198             : 
     199           0 :     return pContext;
     200             : }
     201             : 
     202           0 : void OXMLReport::EndElement()
     203             : {
     204           0 :     Reference< XFunctions > xFunctions = m_xComponent->getFunctions();
     205           0 :     const ORptFilter::TGroupFunctionMap& aFunctions = m_rImport.getFunctions();
     206           0 :     ORptFilter::TGroupFunctionMap::const_iterator aIter = aFunctions.begin();
     207           0 :     const ORptFilter::TGroupFunctionMap::const_iterator aEnd = aFunctions.end();
     208           0 :     for (; aIter != aEnd; ++aIter)
     209           0 :         xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(aIter->second));
     210             : 
     211           0 :     if ( !m_aMasterFields.empty() )
     212           0 :         m_xComponent->setMasterFields(Sequence< OUString>(&*m_aMasterFields.begin(),m_aMasterFields.size()));
     213           0 :     if ( !m_aDetailFields.empty() )
     214           0 :         m_xComponent->setDetailFields(Sequence< OUString>(&*m_aDetailFields.begin(),m_aDetailFields.size()));
     215           0 : }
     216             : 
     217           0 : void OXMLReport::addMasterDetailPair(const ::std::pair< OUString,OUString >& _aPair)
     218             : {
     219           0 :     m_aMasterFields.push_back(_aPair.first);
     220           0 :     m_aDetailFields.push_back(_aPair.second);
     221           0 : }
     222             : 
     223             : } // namespace rptxml
     224             : 
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10