LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/reportdesign/source/filter/xml - xmlFixedContent.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 72 0.0 %
Date: 2013-07-09 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 <xmloff/xmltoken.hxx>
      22             : #include <xmloff/xmlnmspe.hxx>
      23             : #include <xmloff/nmspmap.hxx>
      24             : #include "xmlEnums.hxx"
      25             : #include "xmlReportElement.hxx"
      26             : #include <tools/debug.hxx>
      27             : #include <com/sun/star/report/XShape.hpp>
      28             : #include "xmlCell.hxx"
      29             : #include "xmlstrings.hrc"
      30             : #include <com/sun/star/report/XFormattedField.hpp>
      31             : #include <com/sun/star/report/XFixedText.hpp>
      32             : #include <com/sun/star/text/ControlCharacter.hpp>
      33             : #include "xmlTable.hxx"
      34             : #include <xmloff/XMLCharContext.hxx>
      35             : 
      36             : namespace rptxml
      37             : {
      38             :     using namespace ::com::sun::star;
      39             : 
      40           0 : class OXMLCharContent : public XMLCharContext
      41             : {
      42             :     OXMLFixedContent* m_pFixedContent;
      43             :     OXMLCharContent(const OXMLCharContent&);
      44             :     OXMLCharContent operator =(const OXMLCharContent&);
      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             :             sal_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);
      63             :     virtual void InsertString(const OUString& _sString);
      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             :         sal_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             : DBG_NAME( rpt_OXMLFixedContent )
     110             : 
     111           0 : OXMLFixedContent::OXMLFixedContent( ORptFilter& rImport,
     112             :                 sal_uInt16 nPrfx, const OUString& rLName
     113             :                 ,OXMLCell& _rCell
     114             :                 ,OXMLTable* _pContainer
     115             :                 ,OXMLFixedContent* _pInP) :
     116             :     OXMLReportElementBase( rImport, nPrfx, rLName,NULL,_pContainer)
     117             : ,m_rCell(_rCell)
     118             : ,m_pInP(_pInP)
     119           0 : ,m_bFormattedField(false)
     120             : {
     121             :     DBG_CTOR( rpt_OXMLFixedContent,NULL);
     122           0 : }
     123             : // -----------------------------------------------------------------------------
     124             : 
     125           0 : OXMLFixedContent::~OXMLFixedContent()
     126             : {
     127             : 
     128             :     DBG_DTOR( rpt_OXMLFixedContent,NULL);
     129           0 : }
     130             : // -----------------------------------------------------------------------------
     131             : // -----------------------------------------------------------------------------
     132           0 : SvXMLImportContext* OXMLFixedContent::_CreateChildContext(
     133             :         sal_uInt16 nPrefix,
     134             :         const OUString& rLocalName,
     135             :         const Reference< XAttributeList > & xAttrList )
     136             : {
     137           0 :     SvXMLImportContext *pContext = OXMLReportElementBase::_CreateChildContext(nPrefix,rLocalName,xAttrList);
     138           0 :     if ( pContext )
     139           0 :         return pContext;
     140             : 
     141           0 :     static const OUString s_sStringConcat(" & ");
     142           0 :     const SvXMLTokenMap&    rTokenMap   = m_rImport.GetCellElemTokenMap();
     143           0 :     Reference<XComponentContext> xContext = m_rImport.GetComponentContext();
     144             : 
     145           0 :     m_rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     146           0 :     const sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
     147           0 :     switch( nToken )
     148             :     {
     149             :         case XML_TOK_P:
     150           0 :             pContext = new OXMLFixedContent(m_rImport,nPrefix, rLocalName,m_rCell,m_pContainer,this);
     151           0 :             break;
     152             :         case XML_TOK_TEXT_TAB_STOP:
     153             :             pContext = new OXMLCharContent( m_rImport, this,nPrefix,
     154             :                                                 rLocalName, xAttrList,
     155           0 :                                                 0x0009, sal_False );
     156           0 :             break;
     157             : 
     158             :         case XML_TOK_TEXT_LINE_BREAK:
     159             :             pContext = new OXMLCharContent( m_rImport, this,nPrefix,
     160             :                                                 rLocalName, xAttrList,
     161           0 :                                                 ControlCharacter::LINE_BREAK );
     162           0 :             break;
     163             : 
     164             :         case XML_TOK_TEXT_S:
     165             :             pContext = new OXMLCharContent( m_rImport, this,nPrefix,
     166             :                                                 rLocalName, xAttrList,
     167           0 :                                                 0x0020, sal_True );
     168           0 :             break;
     169             :         case XML_TOK_PAGE_NUMBER:
     170           0 :             m_sPageText += s_sStringConcat + OUString(" PageNumber()");
     171           0 :             m_bFormattedField = true;
     172           0 :             break;
     173             :         case XML_TOK_PAGE_COUNT:
     174           0 :             m_sPageText += s_sStringConcat + OUString(" PageCount()");
     175           0 :             m_bFormattedField = true;
     176           0 :             break;
     177             :         default:
     178             :             ;
     179             :     }
     180           0 :     return pContext;
     181             : }
     182             : // -----------------------------------------------------------------------------
     183           0 : void OXMLFixedContent::EndElement()
     184             : {
     185           0 :     if ( m_pInP )
     186             :     {
     187           0 :         const Reference<XMultiServiceFactory> xFactor(m_rImport.GetModel(),uno::UNO_QUERY);
     188           0 :         if ( m_bFormattedField )
     189             :         {
     190           0 :             uno::Reference< uno::XInterface> xInt = xFactor->createInstance(SERVICE_FORMATTEDFIELD);
     191           0 :             Reference< report::XFormattedField > xControl(xInt,uno::UNO_QUERY);
     192           0 :             xControl->setDataField(OUString("rpt:") + m_sPageText);
     193             :              OSL_ENSURE(xControl.is(),"Could not create FormattedField!");
     194           0 :             m_pInP->m_xComponent = xControl.get();
     195           0 :             m_xComponent = xControl.get();
     196             :         }
     197             :         else
     198             :         {
     199           0 :             Reference< XFixedText > xControl(xFactor->createInstance(SERVICE_FIXEDTEXT),uno::UNO_QUERY);
     200             :              OSL_ENSURE(xControl.is(),"Could not create FixedContent!");
     201           0 :             m_pInP->m_xComponent = xControl.get();
     202           0 :             m_xComponent = xControl.get();
     203           0 :             xControl->setLabel(m_sLabel);
     204             :         }
     205             : 
     206           0 :         m_pContainer->addCell(m_xComponent);
     207           0 :         m_rCell.setComponent(m_xComponent);
     208             : 
     209           0 :         OXMLReportElementBase::EndElement();
     210             :     }
     211           0 : }
     212             : // -----------------------------------------------------------------------------
     213           0 : void OXMLFixedContent::Characters( const OUString& rChars )
     214             : {
     215           0 :     m_sLabel += rChars;
     216           0 :     if ( !rChars.isEmpty() )
     217             :     {
     218           0 :         static const OUString s_Quote("\"");
     219           0 :         if ( !m_sPageText.isEmpty() )
     220             :         {
     221           0 :             static const OUString s_sStringConcat(" & ");
     222           0 :             m_sPageText += s_sStringConcat;
     223             :         }
     224             : 
     225           0 :         m_sPageText += s_Quote + rChars + s_Quote;
     226             :     }
     227           0 : }
     228             : 
     229             : //----------------------------------------------------------------------------
     230             : } // namespace rptxml
     231             : // -----------------------------------------------------------------------------
     232             : 
     233             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10