LCOV - code coverage report
Current view: top level - libreoffice/reportdesign/source/filter/xml - xmlSubDocument.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 55 0.0 %
Date: 2012-12-27 Functions: 0 6 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 "xmlSubDocument.hxx"
      20             : #include "xmlCell.hxx"
      21             : #include "xmlfilter.hxx"
      22             : #include <xmloff/xmltoken.hxx>
      23             : #include <xmloff/xmlnmspe.hxx>
      24             : #include <xmloff/nmspmap.hxx>
      25             : #include "xmlEnums.hxx"
      26             : #include "xmlMasterFields.hxx"
      27             : #include "xmlTable.hxx"
      28             : #include <tools/debug.hxx>
      29             : #include <comphelper/property.hxx>
      30             : #include <com/sun/star/report/XReportControlModel.hpp>
      31             : 
      32             : namespace rptxml
      33             : {
      34             :     using namespace ::com::sun::star;
      35             :     using namespace ::com::sun::star::report;
      36             :     using namespace ::com::sun::star::uno;
      37             :     using namespace ::com::sun::star::xml::sax;
      38             : DBG_NAME( rpt_OXMLSubDocument )
      39             : 
      40           0 : OXMLSubDocument::OXMLSubDocument( ORptFilter& rImport,
      41             :                 sal_uInt16 nPrfx
      42             :                 ,const ::rtl::OUString& rLName
      43             :                 ,const Reference< XReportComponent > & _xComponent
      44             :                 ,OXMLTable* _pContainer
      45             :                 ,OXMLCell* _pCellParent) :
      46             :     OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer)
      47             : ,m_xFake(_xComponent)
      48             : ,m_pCellParent(_pCellParent)
      49             : ,m_nCurrentCount(0)
      50           0 : ,m_bContainsShape(false)
      51             : {
      52             :     DBG_CTOR( rpt_OXMLSubDocument,NULL);
      53             : 
      54           0 : }
      55             : // -----------------------------------------------------------------------------
      56             : 
      57           0 : OXMLSubDocument::~OXMLSubDocument()
      58             : {
      59             :     DBG_DTOR( rpt_OXMLSubDocument,NULL);
      60           0 : }
      61             : 
      62             : // -----------------------------------------------------------------------------
      63           0 : SvXMLImportContext* OXMLSubDocument::_CreateChildContext(
      64             :         sal_uInt16 _nPrefix,
      65             :         const ::rtl::OUString& _rLocalName,
      66             :         const Reference< XAttributeList > & xAttrList )
      67             : {
      68           0 :     SvXMLImportContext *pContext = OXMLReportElementBase::_CreateChildContext(_nPrefix,_rLocalName,xAttrList);
      69           0 :     if ( pContext )
      70           0 :         return pContext;
      71           0 :     const SvXMLTokenMap&    rTokenMap   = static_cast<ORptFilter&>(GetImport()).GetReportElemTokenMap();
      72             : 
      73           0 :     switch( rTokenMap.Get( _nPrefix, _rLocalName ) )
      74             :     {
      75             :         case XML_TOK_MASTER_DETAIL_FIELDS:
      76             :             {
      77           0 :                 GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
      78           0 :                 pContext = new OXMLMasterFields(static_cast<ORptFilter&>(GetImport()), _nPrefix, _rLocalName,xAttrList ,this);
      79             :             }
      80           0 :             break;
      81             :         case XML_TOK_SUB_FRAME:
      82             :             {
      83           0 :                 if ( !m_bContainsShape )
      84           0 :                     m_nCurrentCount = m_pContainer->getSection()->getCount();
      85           0 :                 UniReference< XMLShapeImportHelper > xShapeImportHelper = GetImport().GetShapeImport();
      86           0 :                 uno::Reference< drawing::XShapes > xShapes = m_pContainer->getSection().get();
      87           0 :                 pContext = xShapeImportHelper->CreateGroupChildContext(GetImport(),_nPrefix,_rLocalName,xAttrList,xShapes);
      88           0 :                 m_bContainsShape = true;
      89           0 :                 if (m_pCellParent)
      90             :                 {
      91             :                     // #i94115 say to the parent Cell it contains shapes
      92           0 :                     m_pCellParent->setContainsShape(true);
      93           0 :                 }
      94             :             }
      95           0 :             break;
      96             :         default:
      97           0 :             break;
      98             :     }
      99             : 
     100           0 :     if( !pContext )
     101           0 :         pContext = new SvXMLImportContext( GetImport(), _nPrefix, _rLocalName );
     102             : 
     103           0 :     return pContext;
     104             : }
     105             : // -----------------------------------------------------------------------------
     106           0 : void OXMLSubDocument::EndElement()
     107             : {
     108           0 :     if ( m_bContainsShape )
     109             :     {
     110           0 :         m_xComponent.set(m_pContainer->getSection()->getByIndex(m_nCurrentCount),uno::UNO_QUERY);
     111           0 :         if ( m_xComponent.is() )
     112             :         {
     113           0 :             if ( !m_aMasterFields.empty() )
     114           0 :                 m_xComponent->setMasterFields(Sequence< ::rtl::OUString>(&*m_aMasterFields.begin(),m_aMasterFields.size()));
     115           0 :             if ( !m_aDetailFields.empty() )
     116           0 :                 m_xComponent->setDetailFields(Sequence< ::rtl::OUString>(&*m_aDetailFields.begin(),m_aDetailFields.size()));
     117             : 
     118           0 :             m_xComponent->setName(m_xFake->getName());
     119           0 :             m_xComponent->setPrintRepeatedValues(m_xFake->getPrintRepeatedValues());
     120           0 :             uno::Reference< report::XReportControlModel >   xFakeModel(m_xFake,uno::UNO_QUERY);
     121           0 :             uno::Reference< report::XReportControlModel >   xComponentModel(m_xComponent,uno::UNO_QUERY);
     122           0 :             if ( xComponentModel.is() && xFakeModel.is() )
     123             :             {
     124           0 :                 const sal_Int32 nCount = xFakeModel->getCount();
     125             :                 try
     126             :                 {
     127           0 :                     for (sal_Int32 i = 0; i < nCount ; ++i)
     128             :                     {
     129           0 :                         uno::Reference< report::XFormatCondition > xCond(xFakeModel->getByIndex(i),uno::UNO_QUERY);
     130           0 :                         uno::Reference< report::XFormatCondition > xNewCond = xComponentModel->createFormatCondition();
     131           0 :                         ::comphelper::copyProperties(xCond.get(),xNewCond.get());
     132           0 :                         xComponentModel->insertByIndex(xComponentModel->getCount(),uno::makeAny(xNewCond));
     133           0 :                     }
     134             :                 }
     135           0 :                 catch(uno::Exception&)
     136             :                 {
     137             :                     OSL_FAIL("Can not access format condition!");
     138             :                 }
     139             : 
     140           0 :             }
     141             :         }
     142             :     }
     143           0 : }
     144             : // -----------------------------------------------------------------------------
     145           0 : void OXMLSubDocument::addMasterDetailPair(const ::std::pair< ::rtl::OUString,::rtl::OUString >& _aPair)
     146             : {
     147           0 :     m_aMasterFields.push_back(_aPair.first);
     148           0 :     m_aDetailFields.push_back(_aPair.second);
     149           0 : }
     150             : //----------------------------------------------------------------------------
     151             : } // namespace rptxml
     152             : // -----------------------------------------------------------------------------
     153             : 
     154             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10