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

Generated by: LCOV version 1.10