LCOV - code coverage report
Current view: top level - reportdesign/source/filter/xml - xmlFixedContent.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 72 0.0 %
Date: 2014-11-03 Functions: 0 12 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 "xmlFixedContent.hxx"
      20             : #include "xmlfilter.hxx"
      21             : #include <boost/noncopyable.hpp>
      22             : #include <xmloff/xmltoken.hxx>
      23             : #include <xmloff/xmlnmspe.hxx>
      24             : #include <xmloff/nmspmap.hxx>
      25             : #include "xmlEnums.hxx"
      26             : #include "xmlReportElement.hxx"
      27             : #include <tools/debug.hxx>
      28             : #include <com/sun/star/report/XShape.hpp>
      29             : #include "xmlCell.hxx"
      30             : #include "xmlstrings.hrc"
      31             : #include <com/sun/star/report/XFormattedField.hpp>
      32             : #include <com/sun/star/report/XFixedText.hpp>
      33             : #include <com/sun/star/text/ControlCharacter.hpp>
      34             : #include "xmlTable.hxx"
      35             : #include <xmloff/XMLCharContext.hxx>
      36             : 
      37             : namespace rptxml
      38             : {
      39             :     using namespace ::com::sun::star;
      40             : 
      41           0 : class OXMLCharContent: public XMLCharContext, private boost::noncopyable
      42             : {
      43             :     OXMLFixedContent* m_pFixedContent;
      44             : 
      45             : public:
      46             :     OXMLCharContent(
      47             :             SvXMLImport& rImport,
      48             :             OXMLFixedContent* _pFixedContent,
      49             :             sal_uInt16 nPrfx,
      50             :             const OUString& rLName,
      51             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList,
      52             :             sal_Unicode c,
      53             :             bool bCount );
      54             :     OXMLCharContent(
      55             :             SvXMLImport& rImport,
      56             :             OXMLFixedContent* _pFixedContent,
      57             :             sal_uInt16 nPrfx,
      58             :             const OUString& rLName,
      59             :             const uno::Reference< xml::sax::XAttributeList > & xAttrList,
      60             :             sal_Int16 nControl );
      61             : 
      62             :     virtual void InsertControlCharacter(sal_Int16   _nControl) SAL_OVERRIDE;
      63             :     virtual void InsertString(const OUString& _sString) SAL_OVERRIDE;
      64             : };
      65           0 : OXMLCharContent::OXMLCharContent(
      66             :         SvXMLImport& rImport,
      67             :         OXMLFixedContent* _pFixedContent,
      68             :         sal_uInt16 nPrfx,
      69             :         const OUString& rLName,
      70             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList,
      71             :         sal_Unicode c,
      72             :         bool bCount )
      73             :     : XMLCharContext(rImport,nPrfx,rLName,xAttrList,c,bCount)
      74           0 :     ,m_pFixedContent(_pFixedContent)
      75             : {
      76           0 : }
      77             : 
      78           0 : OXMLCharContent::OXMLCharContent(
      79             :         SvXMLImport& rImport,
      80             :         OXMLFixedContent* _pFixedContent,
      81             :         sal_uInt16 nPrfx,
      82             :         const OUString& rLName,
      83             :         const uno::Reference< xml::sax::XAttributeList > & xAttrList,
      84             :         sal_Int16 nControl )
      85             :     : XMLCharContext(rImport,nPrfx,rLName,xAttrList,nControl)
      86           0 :     ,m_pFixedContent(_pFixedContent)
      87             : {
      88           0 : }
      89             : 
      90           0 : void OXMLCharContent::InsertControlCharacter(sal_Int16   _nControl)
      91             : {
      92           0 :     switch( _nControl )
      93             :     {
      94             :         case ControlCharacter::LINE_BREAK:
      95           0 :             m_pFixedContent->Characters(OUString("\n"));
      96           0 :             break;
      97             :         default:
      98             :             OSL_FAIL("Not supported control character");
      99           0 :             break;
     100             :     }
     101           0 : }
     102             : 
     103           0 : void OXMLCharContent::InsertString(const OUString& _sString)
     104             : {
     105           0 :     m_pFixedContent->Characters(_sString);
     106           0 : }
     107             : 
     108             : 
     109             : 
     110           0 : OXMLFixedContent::OXMLFixedContent( ORptFilter& rImport,
     111             :                 sal_uInt16 nPrfx, const OUString& rLName
     112             :                 ,OXMLCell& _rCell
     113             :                 ,OXMLTable* _pContainer
     114             :                 ,OXMLFixedContent* _pInP) :
     115             :     OXMLReportElementBase( rImport, nPrfx, rLName,NULL,_pContainer)
     116             : ,m_rCell(_rCell)
     117             : ,m_pInP(_pInP)
     118           0 : ,m_bFormattedField(false)
     119             : {
     120           0 : }
     121             : 
     122             : 
     123           0 : OXMLFixedContent::~OXMLFixedContent()
     124             : {
     125             : 
     126           0 : }
     127             : 
     128             : 
     129           0 : SvXMLImportContext* OXMLFixedContent::_CreateChildContext(
     130             :         sal_uInt16 nPrefix,
     131             :         const OUString& rLocalName,
     132             :         const Reference< XAttributeList > & xAttrList )
     133             : {
     134           0 :     SvXMLImportContext *pContext = OXMLReportElementBase::_CreateChildContext(nPrefix,rLocalName,xAttrList);
     135           0 :     if ( pContext )
     136           0 :         return pContext;
     137             : 
     138           0 :     static const OUString s_sStringConcat(" & ");
     139           0 :     const SvXMLTokenMap&    rTokenMap   = m_rImport.GetCellElemTokenMap();
     140           0 :     Reference<XComponentContext> xContext = m_rImport.GetComponentContext();
     141             : 
     142           0 :     m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     143           0 :     const sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
     144           0 :     switch( nToken )
     145             :     {
     146             :         case XML_TOK_P:
     147           0 :             pContext = new OXMLFixedContent(m_rImport,nPrefix, rLocalName,m_rCell,m_pContainer,this);
     148           0 :             break;
     149             :         case XML_TOK_TEXT_TAB_STOP:
     150             :             pContext = new OXMLCharContent( m_rImport, this,nPrefix,
     151             :                                                 rLocalName, xAttrList,
     152           0 :                                                 0x0009, false );
     153           0 :             break;
     154             : 
     155             :         case XML_TOK_TEXT_LINE_BREAK:
     156             :             pContext = new OXMLCharContent( m_rImport, this,nPrefix,
     157             :                                                 rLocalName, xAttrList,
     158           0 :                                                 ControlCharacter::LINE_BREAK );
     159           0 :             break;
     160             : 
     161             :         case XML_TOK_TEXT_S:
     162             :             pContext = new OXMLCharContent( m_rImport, this,nPrefix,
     163             :                                                 rLocalName, xAttrList,
     164           0 :                                                 0x0020, true );
     165           0 :             break;
     166             :         case XML_TOK_PAGE_NUMBER:
     167           0 :             m_sPageText += s_sStringConcat + " PageNumber()";
     168           0 :             m_bFormattedField = true;
     169           0 :             break;
     170             :         case XML_TOK_PAGE_COUNT:
     171           0 :             m_sPageText += s_sStringConcat + " PageCount()";
     172           0 :             m_bFormattedField = true;
     173           0 :             break;
     174             :         default:
     175             :             ;
     176             :     }
     177           0 :     return pContext;
     178             : }
     179             : 
     180           0 : void OXMLFixedContent::EndElement()
     181             : {
     182           0 :     if ( m_pInP )
     183             :     {
     184           0 :         const Reference<XMultiServiceFactory> xFactor(m_rImport.GetModel(),uno::UNO_QUERY);
     185           0 :         if ( m_bFormattedField )
     186             :         {
     187           0 :             uno::Reference< uno::XInterface> xInt = xFactor->createInstance(SERVICE_FORMATTEDFIELD);
     188           0 :             Reference< report::XFormattedField > xControl(xInt,uno::UNO_QUERY);
     189           0 :             xControl->setDataField(OUString("rpt:") + m_sPageText);
     190             :              OSL_ENSURE(xControl.is(),"Could not create FormattedField!");
     191           0 :             m_pInP->m_xComponent = xControl.get();
     192           0 :             m_xComponent = xControl.get();
     193             :         }
     194             :         else
     195             :         {
     196           0 :             Reference< XFixedText > xControl(xFactor->createInstance(SERVICE_FIXEDTEXT),uno::UNO_QUERY);
     197             :              OSL_ENSURE(xControl.is(),"Could not create FixedContent!");
     198           0 :             m_pInP->m_xComponent = xControl.get();
     199           0 :             m_xComponent = xControl.get();
     200           0 :             xControl->setLabel(m_sLabel);
     201             :         }
     202             : 
     203           0 :         m_pContainer->addCell(m_xComponent);
     204           0 :         m_rCell.setComponent(m_xComponent);
     205             : 
     206           0 :         OXMLReportElementBase::EndElement();
     207             :     }
     208           0 : }
     209             : 
     210           0 : void OXMLFixedContent::Characters( const OUString& rChars )
     211             : {
     212           0 :     m_sLabel += rChars;
     213           0 :     if ( !rChars.isEmpty() )
     214             :     {
     215           0 :         static const OUString s_Quote("\"");
     216           0 :         if ( !m_sPageText.isEmpty() )
     217             :         {
     218           0 :             static const OUString s_sStringConcat(" & ");
     219           0 :             m_sPageText += s_sStringConcat;
     220             :         }
     221             : 
     222           0 :         m_sPageText += s_Quote + rChars + s_Quote;
     223             :     }
     224           0 : }
     225             : 
     226             : 
     227             : } // namespace rptxml
     228             : 
     229             : 
     230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10