LCOV - code coverage report
Current view: top level - reportdesign/source/filter/xml - xmlReport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 96 0.0 %
Date: 2012-08-25 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 175 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #include "xmlReport.hxx"
      29                 :            : #include "xmlfilter.hxx"
      30                 :            : #include <xmloff/xmltoken.hxx>
      31                 :            : #include <xmloff/xmlnmspe.hxx>
      32                 :            : #include <xmloff/nmspmap.hxx>
      33                 :            : #include <xmloff/xmluconv.hxx>
      34                 :            : #include "xmlHelper.hxx"
      35                 :            : #include "xmlGroup.hxx"
      36                 :            : #include "xmlSection.hxx"
      37                 :            : #include "xmlEnums.hxx"
      38                 :            : #include "xmlFunction.hxx"
      39                 :            : #include <tools/diagnose_ex.h>
      40                 :            : #include <com/sun/star/sdb/CommandType.hpp>
      41                 :            : #include "xmlMasterFields.hxx"
      42                 :            : 
      43                 :            : namespace rptxml
      44                 :            : {
      45                 :            :     using namespace ::com::sun::star;
      46                 :            :     using namespace uno;
      47                 :            :     using namespace xml::sax;
      48                 :            : 
      49                 :            : DBG_NAME( rpt_OXMLReport )
      50                 :            : 
      51                 :          0 : OXMLReport::OXMLReport( ORptFilter& rImport,
      52                 :            :                 sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
      53                 :            :                 const Reference< XAttributeList > & _xAttrList
      54                 :            :                 ,const uno::Reference< report::XReportDefinition >& _xComponent
      55                 :            :                 ,OXMLTable* _pContainer) :
      56                 :          0 :     OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer)
      57 [ #  # ][ #  # ]:          0 :     ,m_xComponent(_xComponent)
         [ #  # ][ #  # ]
      58                 :            : {
      59                 :            :     DBG_CTOR( rpt_OXMLReport,NULL);
      60                 :            :     OSL_ENSURE(m_xComponent.is(),"No Report definition!");
      61                 :            : 
      62         [ #  # ]:          0 :     impl_initRuntimeDefaults();
      63                 :            : 
      64                 :          0 :     const SvXMLNamespaceMap& rMap = m_rImport.GetNamespaceMap();
      65         [ #  # ]:          0 :     const SvXMLTokenMap& rTokenMap = m_rImport.GetReportElemTokenMap();
      66                 :            : 
      67 [ #  # ][ #  # ]:          0 :     const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
                 [ #  # ]
      68 [ #  # ][ #  # ]:          0 :     static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
         [ #  # ][ #  # ]
      69                 :            :     try
      70                 :            :     {
      71         [ #  # ]:          0 :         for(sal_Int16 i = 0; i < nLength; ++i)
      72                 :            :         {
      73                 :          0 :          ::rtl::OUString sLocalName;
      74 [ #  # ][ #  # ]:          0 :             const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
      75         [ #  # ]:          0 :             const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
      76 [ #  # ][ #  # ]:          0 :             const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
      77                 :            : 
      78 [ #  # ][ #  #  :          0 :             switch( rTokenMap.Get( nPrefix, sLocalName ) )
          #  #  #  #  #  
                      # ]
      79                 :            :             {
      80                 :            :                 case XML_TOK_COMMAND_TYPE:
      81                 :            :                     {
      82                 :          0 :                         sal_uInt16 nRet = static_cast<sal_uInt16>(sdb::CommandType::COMMAND);
      83         [ #  # ]:          0 :                         const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetCommandTypeOptions();
      84         [ #  # ]:          0 :                         SvXMLUnitConverter::convertEnum( nRet, sValue, aXML_EnumMap );
      85 [ #  # ][ #  # ]:          0 :                         m_xComponent->setCommandType(nRet);
      86                 :            :                     }
      87                 :          0 :                     break;
      88                 :            :                 case XML_TOK_COMMAND:
      89 [ #  # ][ #  # ]:          0 :                     m_xComponent->setCommand(sValue);
      90                 :          0 :                     break;
      91                 :            :                 case XML_TOK_FILTER:
      92 [ #  # ][ #  # ]:          0 :                     m_xComponent->setFilter(sValue);
      93                 :          0 :                     break;
      94                 :            :                 case XML_TOK_CAPTION:
      95 [ #  # ][ #  # ]:          0 :                     m_xComponent->setCaption(sValue);
      96                 :          0 :                     break;
      97                 :            :                 case XML_TOK_ESCAPE_PROCESSING:
      98 [ #  # ][ #  # ]:          0 :                     m_xComponent->setEscapeProcessing(sValue == s_sTRUE);
      99                 :          0 :                     break;
     100                 :            :                 case XML_TOK_REPORT_MIMETYPE:
     101 [ #  # ][ #  # ]:          0 :                     m_xComponent->setMimeType(sValue);
     102                 :          0 :                     break;
     103                 :            :                 case XML_TOK_REPORT_NAME:
     104 [ #  # ][ #  # ]:          0 :                     m_xComponent->setName(sValue);
     105                 :          0 :                     break;
     106                 :            :                 default:
     107                 :          0 :                     break;
     108                 :            :             }
     109         [ #  # ]:          0 :         }
     110                 :            :     }
     111         [ #  # ]:          0 :     catch(Exception&)
     112                 :            :     {
     113                 :            :         OSL_FAIL("Exception catched while filling the report definition props");
     114                 :            :     }
     115                 :          0 : }
     116                 :            : // -----------------------------------------------------------------------------
     117                 :            : 
     118                 :          0 : OXMLReport::~OXMLReport()
     119                 :            : {
     120                 :            :     DBG_DTOR( rpt_OXMLReport,NULL);
     121         [ #  # ]:          0 : }
     122                 :            : 
     123                 :            : // -----------------------------------------------------------------------------
     124                 :            : 
     125                 :          0 : void OXMLReport::impl_initRuntimeDefaults() const
     126                 :            : {
     127                 :            :     OSL_PRECOND( m_xComponent.is(), "OXMLReport::impl_initRuntimeDefaults: no component!" );
     128         [ #  # ]:          0 :     if ( !m_xComponent.is() )
     129         [ #  # ]:          0 :         return;
     130                 :            : 
     131                 :            :     try
     132                 :            :     {
     133 [ #  # ][ #  # ]:          0 :         m_xComponent->setCommandType( sdb::CommandType::COMMAND );
     134                 :            :     }
     135                 :          0 :     catch( const Exception& )
     136                 :            :     {
     137                 :            :         DBG_UNHANDLED_EXCEPTION();
     138                 :            :     }
     139                 :            : }
     140                 :            : 
     141                 :            : // -----------------------------------------------------------------------------
     142                 :            : 
     143                 :          0 : SvXMLImportContext* OXMLReport::CreateChildContext(
     144                 :            :         sal_uInt16 nPrefix,
     145                 :            :         const ::rtl::OUString& rLocalName,
     146                 :            :         const Reference< XAttributeList > & xAttrList )
     147                 :            : {
     148                 :          0 :     SvXMLImportContext *pContext = _CreateChildContext(nPrefix,rLocalName,xAttrList);
     149         [ #  # ]:          0 :     if ( pContext )
     150                 :          0 :         return pContext;
     151                 :          0 :     const SvXMLTokenMap&    rTokenMap   = m_rImport.GetReportElemTokenMap();
     152                 :            : 
     153   [ #  #  #  #  :          0 :     switch( rTokenMap.Get( nPrefix, rLocalName ) )
             #  #  #  #  
                      # ]
     154                 :            :     {
     155                 :            :         case XML_TOK_REPORT_FUNCTION:
     156                 :            :             {
     157                 :          0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     158 [ #  # ][ #  # ]:          0 :                 pContext = new OXMLFunction( m_rImport, nPrefix, rLocalName,xAttrList,m_xComponent.get(),true);
                 [ #  # ]
     159                 :            :             }
     160                 :          0 :             break;
     161                 :            :         case XML_TOK_MASTER_DETAIL_FIELDS:
     162                 :          0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     163         [ #  # ]:          0 :                 pContext = new OXMLMasterFields(m_rImport, nPrefix, rLocalName,xAttrList ,this);
     164                 :          0 :             break;
     165                 :            :         case XML_TOK_REPORT_HEADER:
     166                 :            :             {
     167                 :          0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     168                 :          0 :                 m_xComponent->setReportHeaderOn(sal_True);
     169 [ #  # ][ #  # ]:          0 :                 pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getReportHeader());
     170                 :            :             }
     171                 :          0 :             break;
     172                 :            :         case XML_TOK_PAGE_HEADER:
     173                 :            :             {
     174                 :          0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     175                 :          0 :                 m_xComponent->setPageHeaderOn(sal_True);
     176 [ #  # ][ #  # ]:          0 :                 pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getPageHeader());
     177                 :            :             }
     178                 :          0 :             break;
     179                 :            :         case XML_TOK_GROUP:
     180                 :          0 :             m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     181         [ #  # ]:          0 :             pContext = new OXMLGroup( m_rImport, nPrefix, rLocalName,xAttrList);
     182                 :          0 :             break;
     183                 :            :         case XML_TOK_DETAIL:
     184                 :            :             {
     185                 :          0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     186 [ #  # ][ #  # ]:          0 :                 pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getDetail());
     187                 :            :             }
     188                 :          0 :             break;
     189                 :            :         case XML_TOK_PAGE_FOOTER:
     190                 :            :             {
     191                 :          0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     192                 :          0 :                 m_xComponent->setPageFooterOn(sal_True);
     193 [ #  # ][ #  # ]:          0 :                 pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getPageFooter(),sal_False);
     194                 :            :             }
     195                 :          0 :             break;
     196                 :            :         case XML_TOK_REPORT_FOOTER:
     197                 :            :             {
     198                 :          0 :                 m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     199                 :          0 :                 m_xComponent->setReportFooterOn(sal_True);
     200 [ #  # ][ #  # ]:          0 :                 pContext = new OXMLSection( m_rImport, nPrefix, rLocalName,xAttrList ,m_xComponent->getReportFooter());
     201                 :            :             }
     202                 :          0 :             break;
     203                 :            :         default:
     204                 :          0 :             break;
     205                 :            :     }
     206                 :            : 
     207         [ #  # ]:          0 :     if( !pContext )
     208         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     209                 :            : 
     210                 :            : 
     211                 :          0 :     return pContext;
     212                 :            : }
     213                 :            : // -----------------------------------------------------------------------------
     214                 :          0 : void OXMLReport::EndElement()
     215                 :            : {
     216 [ #  # ][ #  # ]:          0 :     Reference< XFunctions > xFunctions = m_xComponent->getFunctions();
     217                 :          0 :     const ORptFilter::TGroupFunctionMap& aFunctions = m_rImport.getFunctions();
     218                 :          0 :     ORptFilter::TGroupFunctionMap::const_iterator aIter = aFunctions.begin();
     219                 :          0 :     const ORptFilter::TGroupFunctionMap::const_iterator aEnd = aFunctions.end();
     220         [ #  # ]:          0 :     for (; aIter != aEnd; ++aIter)
     221 [ #  # ][ #  # ]:          0 :         xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(aIter->second));
         [ #  # ][ #  # ]
                 [ #  # ]
     222                 :            : 
     223         [ #  # ]:          0 :     if ( !m_aMasterFields.empty() )
     224 [ #  # ][ #  # ]:          0 :         m_xComponent->setMasterFields(Sequence< ::rtl::OUString>(&*m_aMasterFields.begin(),m_aMasterFields.size()));
         [ #  # ][ #  # ]
     225         [ #  # ]:          0 :     if ( !m_aDetailFields.empty() )
     226 [ #  # ][ #  # ]:          0 :         m_xComponent->setDetailFields(Sequence< ::rtl::OUString>(&*m_aDetailFields.begin(),m_aDetailFields.size()));
         [ #  # ][ #  # ]
     227                 :          0 : }
     228                 :            : // -----------------------------------------------------------------------------
     229                 :          0 : void OXMLReport::addMasterDetailPair(const ::std::pair< ::rtl::OUString,::rtl::OUString >& _aPair)
     230                 :            : {
     231                 :          0 :     m_aMasterFields.push_back(_aPair.first);
     232                 :          0 :     m_aDetailFields.push_back(_aPair.second);
     233                 :          0 : }
     234                 :            : //----------------------------------------------------------------------------
     235                 :            : } // namespace rptxml
     236                 :            : // -----------------------------------------------------------------------------
     237                 :            : 
     238                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10