LCOV - code coverage report
Current view: top level - reportdesign/source/filter/xml - xmlCell.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 129 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 375 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 "xmlCell.hxx"
      29                 :            : #include "xmlHelper.hxx"
      30                 :            : #include <xmloff/xmluconv.hxx>
      31                 :            : #include "xmlfilter.hxx"
      32                 :            : #include <xmloff/xmltoken.hxx>
      33                 :            : #include <xmloff/xmlnmspe.hxx>
      34                 :            : #include <xmloff/nmspmap.hxx>
      35                 :            : #include "xmlEnums.hxx"
      36                 :            : #include <tools/debug.hxx>
      37                 :            : #include "xmlStyleImport.hxx"
      38                 :            : #include <comphelper/namecontainer.hxx>
      39                 :            : #include <comphelper/genericpropertyset.hxx>
      40                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      41                 :            : #include <com/sun/star/report/XShape.hpp>
      42                 :            : #include <com/sun/star/report/XFixedLine.hpp>
      43                 :            : #include <com/sun/star/table/BorderLine.hpp>
      44                 :            : #include "xmlstrings.hrc"
      45                 :            : #include "xmlTable.hxx"
      46                 :            : #include "xmlFormattedField.hxx"
      47                 :            : #include "xmlImage.hxx"
      48                 :            : #include "xmlFixedContent.hxx"
      49                 :            : #include "xmlSubDocument.hxx"
      50                 :            : 
      51                 :            : namespace rptxml
      52                 :            : {
      53                 :            :     using namespace ::comphelper;
      54                 :            :     using namespace ::com::sun::star;
      55                 :            :     using namespace uno;
      56                 :            :     using namespace beans;
      57                 :            :     using namespace xml::sax;
      58                 :            : 
      59                 :            : DBG_NAME( rpt_OXMLCell )
      60                 :            : 
      61                 :          0 : OXMLCell::OXMLCell( ORptFilter& rImport
      62                 :            :                 ,sal_uInt16 nPrfx
      63                 :            :                 ,const ::rtl::OUString& _sLocalName
      64                 :            :                 ,const Reference< XAttributeList > & _xAttrList
      65                 :            :                 ,OXMLTable* _pContainer
      66                 :            :                 ,OXMLCell* _pCell) :
      67                 :            :     SvXMLImportContext( rImport, nPrfx, _sLocalName )
      68                 :            :     ,m_pContainer(_pContainer)
      69                 :            :     ,m_pCell(_pCell)
      70                 :            :     ,m_nCurrentCount(0)
      71                 :          0 :     ,m_bContainsShape(false)
      72                 :            : {
      73                 :            :     DBG_CTOR( rpt_OXMLCell,NULL);
      74         [ #  # ]:          0 :     if ( !m_pCell )
      75                 :          0 :         m_pCell = this;
      76                 :            : 
      77                 :            :     OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
      78                 :          0 :     const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
      79         [ #  # ]:          0 :     const SvXMLTokenMap& rTokenMap = rImport.GetColumnTokenMap();
      80                 :            : 
      81 [ #  # ][ #  # ]:          0 :     const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
                 [ #  # ]
      82         [ #  # ]:          0 :     for(sal_Int16 i = 0; i < nLength; ++i)
      83                 :            :     {
      84                 :          0 :         ::rtl::OUString sLocalName;
      85 [ #  # ][ #  # ]:          0 :         const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
      86         [ #  # ]:          0 :         const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
      87 [ #  # ][ #  # ]:          0 :         const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
      88                 :            : 
      89         [ #  # ]:          0 :         switch( rTokenMap.Get( nPrefix, sLocalName ) )
           [ #  #  #  # ]
      90                 :            :         {
      91                 :            :             case XML_TOK_COLUMN_STYLE_NAME:
      92                 :          0 :                 m_sStyleName = sValue;
      93                 :          0 :                 break;
      94                 :            :             case XML_TOK_NUMBER_COLUMNS_SPANNED:
      95                 :          0 :                 m_pContainer->setColumnSpanned(sValue.toInt32());
      96                 :          0 :                 break;
      97                 :            :             case XML_TOK_NUMBER_ROWS_SPANNED:
      98                 :          0 :                 m_pContainer->setRowSpanned(sValue.toInt32());
      99                 :          0 :                 break;
     100                 :            :             default:
     101                 :          0 :                 break;
     102                 :            :         }
     103                 :          0 :     }
     104                 :          0 : }
     105                 :            : // -----------------------------------------------------------------------------
     106                 :          0 : OXMLCell::~OXMLCell()
     107                 :            : {
     108                 :            :     DBG_DTOR( rpt_OXMLCell,NULL);
     109         [ #  # ]:          0 : }
     110                 :            : // -----------------------------------------------------------------------------
     111                 :          0 : SvXMLImportContext* OXMLCell::CreateChildContext(
     112                 :            :         sal_uInt16 _nPrefix,
     113                 :            :         const ::rtl::OUString& _rLocalName,
     114                 :            :         const Reference< XAttributeList > & xAttrList )
     115                 :            : {
     116                 :          0 :     SvXMLImportContext *pContext = 0;
     117                 :          0 :     ORptFilter& rImport = GetOwnImport();
     118         [ #  # ]:          0 :     const SvXMLTokenMap&    rTokenMap   = rImport.GetCellElemTokenMap();
     119         [ #  # ]:          0 :     Reference<XMultiServiceFactory> xFactor(rImport.GetModel(),uno::UNO_QUERY);
     120 [ #  # ][ #  # ]:          0 :     static const ::rtl::OUString s_sStringConcat(RTL_CONSTASCII_USTRINGPARAM(" & "));
         [ #  # ][ #  # ]
     121                 :            : 
     122         [ #  # ]:          0 :     const sal_uInt16 nToken = rTokenMap.Get( _nPrefix, _rLocalName );
     123   [ #  #  #  #  :          0 :     switch( nToken )
             #  #  #  #  
                      # ]
     124                 :            :     {
     125                 :            :         case XML_TOK_FIXED_CONTENT:
     126                 :            :             {
     127 [ #  # ][ #  # ]:          0 :                 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     128 [ #  # ][ #  # ]:          0 :                 pContext = new OXMLFixedContent( rImport, _nPrefix, _rLocalName,*m_pCell,m_pContainer);
     129                 :            :             }
     130                 :          0 :             break;
     131                 :            :         case XML_TOK_PAGE_NUMBER:
     132         [ #  # ]:          0 :             m_sText += s_sStringConcat + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" PageNumber()"));
     133                 :          0 :             break;
     134                 :            :         case XML_TOK_PAGE_COUNT:
     135         [ #  # ]:          0 :             m_sText += s_sStringConcat + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" PageCount()"));
     136                 :          0 :             break;
     137                 :            :         case XML_TOK_FORMATTED_TEXT:
     138                 :            :             {
     139 [ #  # ][ #  # ]:          0 :                 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     140 [ #  # ][ #  # ]:          0 :                 uno::Reference< uno::XInterface> xInt = xFactor->createInstance(SERVICE_FORMATTEDFIELD);
                 [ #  # ]
     141         [ #  # ]:          0 :                 Reference< report::XFormattedField > xControl(xInt,uno::UNO_QUERY);
     142                 :            : 
     143                 :            :                 OSL_ENSURE(xControl.is(),"Could not create FormattedField!");
     144 [ #  # ][ #  # ]:          0 :                 setComponent(xControl.get());
                 [ #  # ]
     145         [ #  # ]:          0 :                 if ( xControl.is() )
     146 [ #  # ][ #  # ]:          0 :                     pContext = new OXMLFormattedField( rImport, _nPrefix, _rLocalName,xAttrList,xControl.get(),m_pContainer,XML_TOK_PAGE_COUNT == nToken);
         [ #  # ][ #  # ]
     147                 :            :             }
     148                 :          0 :             break;
     149                 :            :         case XML_TOK_IMAGE:
     150                 :            :             {
     151 [ #  # ][ #  # ]:          0 :                 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     152 [ #  # ][ #  # ]:          0 :                 Reference< XImageControl > xControl(xFactor->createInstance(SERVICE_IMAGECONTROL),uno::UNO_QUERY);
         [ #  # ][ #  # ]
     153                 :            : 
     154                 :            :                 OSL_ENSURE(xControl.is(),"Could not create ImageControl!");
     155 [ #  # ][ #  # ]:          0 :                 setComponent(xControl.get());
                 [ #  # ]
     156         [ #  # ]:          0 :                 if ( xControl.is() )
     157 [ #  # ][ #  # ]:          0 :                     pContext = new OXMLImage( rImport, _nPrefix, _rLocalName,xAttrList,xControl.get(),m_pContainer);
         [ #  # ][ #  # ]
     158                 :            :             }
     159                 :          0 :             break;
     160                 :            :         case XML_TOK_SUB_DOCUMENT:
     161                 :            :             {
     162 [ #  # ][ #  # ]:          0 :                 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     163         [ #  # ]:          0 :                 if ( !m_bContainsShape )
     164 [ #  # ][ #  # ]:          0 :                     m_nCurrentCount = m_pContainer->getSection()->getCount();
                 [ #  # ]
     165 [ #  # ][ #  # ]:          0 :                 uno::Reference< uno::XInterface> xInt = xFactor->createInstance(SERVICE_FORMATTEDFIELD);
                 [ #  # ]
     166         [ #  # ]:          0 :                 Reference< report::XFormattedField > xControl(xInt,uno::UNO_QUERY);
     167 [ #  # ][ #  # ]:          0 :                 pContext = new OXMLSubDocument( rImport, _nPrefix, _rLocalName,xControl.get(),m_pContainer, this /* give the current cell as parent*/ );
         [ #  # ][ #  # ]
     168                 :            :             }
     169                 :          0 :             break;
     170                 :            : 
     171                 :            :         case XML_TOK_P:
     172 [ #  # ][ #  # ]:          0 :             pContext = new OXMLCell( rImport, _nPrefix, _rLocalName,xAttrList ,m_pContainer,this);
     173                 :          0 :             break;
     174                 :            :         case XML_TOK_CUSTOM_SHAPE:
     175                 :            :         case XML_TOK_FRAME:
     176                 :            :             {
     177         [ #  # ]:          0 :                 if ( !m_bContainsShape )
     178 [ #  # ][ #  # ]:          0 :                     m_nCurrentCount = m_pContainer->getSection()->getCount();
                 [ #  # ]
     179         [ #  # ]:          0 :                 UniReference< XMLShapeImportHelper > xShapeImportHelper = rImport.GetShapeImport();
     180 [ #  # ][ #  # ]:          0 :                 uno::Reference< drawing::XShapes > xShapes = m_pContainer->getSection().get();
         [ #  # ][ #  # ]
     181 [ #  # ][ #  # ]:          0 :                 pContext = xShapeImportHelper->CreateGroupChildContext(rImport,_nPrefix,_rLocalName,xAttrList,xShapes);
     182         [ #  # ]:          0 :                 m_bContainsShape = true;
     183                 :            :             }
     184                 :          0 :             break;
     185                 :            :         default:
     186                 :          0 :             break;
     187                 :            :     }
     188                 :            : 
     189         [ #  # ]:          0 :     if ( m_xComponent.is() )
     190         [ #  # ]:          0 :         m_pContainer->addCell(m_xComponent);
     191                 :            : 
     192         [ #  # ]:          0 :     if( !pContext )
     193 [ #  # ][ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), _nPrefix, _rLocalName );
     194                 :            : 
     195                 :          0 :     return pContext;
     196                 :            : }
     197                 :            : // -----------------------------------------------------------------------------
     198                 :          0 : void OXMLCell::EndElement()
     199                 :            : {
     200         [ #  # ]:          0 :     if ( m_bContainsShape )
     201                 :            :     {
     202 [ #  # ][ #  # ]:          0 :         const sal_Int32 nCount = m_pContainer->getSection()->getCount();
     203         [ #  # ]:          0 :         for (sal_Int32 i = m_nCurrentCount; i < nCount; ++i)
     204                 :            :         {
     205 [ #  # ][ #  # ]:          0 :             uno::Reference<report::XShape> xShape(m_pContainer->getSection()->getByIndex(i),uno::UNO_QUERY);
         [ #  # ][ #  # ]
     206         [ #  # ]:          0 :             if ( xShape.is() )
     207 [ #  # ][ #  # ]:          0 :                 m_pContainer->addCell(xShape.get());
                 [ #  # ]
     208                 :          0 :         }
     209                 :            :     }
     210 [ #  # ][ #  # ]:          0 :     if ( m_pCell != this && !m_sText.isEmpty() )
                 [ #  # ]
     211                 :            :     {
     212                 :          0 :         ORptFilter& rImport = GetOwnImport();
     213         [ #  # ]:          0 :         Reference<XMultiServiceFactory> xFactor(rImport.GetModel(),uno::UNO_QUERY);
     214 [ #  # ][ #  # ]:          0 :         uno::Reference< uno::XInterface> xInt = xFactor->createInstance(SERVICE_FORMATTEDFIELD);
                 [ #  # ]
     215         [ #  # ]:          0 :         Reference< report::XFormattedField > xControl(xInt,uno::UNO_QUERY);
     216 [ #  # ][ #  # ]:          0 :         xControl->setDataField(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:")) + m_sText);
                 [ #  # ]
     217                 :            : 
     218                 :            :         OSL_ENSURE(xControl.is(),"Could not create FormattedField!");
     219 [ #  # ][ #  # ]:          0 :         setComponent(xControl.get());
                 [ #  # ]
     220 [ #  # ][ #  # ]:          0 :         m_xComponent = xControl.get();
     221 [ #  # ][ #  # ]:          0 :         m_pContainer->getSection()->add(m_xComponent.get());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     222         [ #  # ]:          0 :         m_pContainer->addCell(m_xComponent);
     223                 :            :     }
     224                 :            :     // check if we have a FixedLine
     225 [ #  # ][ #  # ]:          0 :     else if ( !m_sStyleName.isEmpty() && !m_xComponent.is() && m_pCell == this )
         [ #  # ][ #  # ]
     226                 :            :     {
     227                 :          0 :         ORptFilter& rImport = GetOwnImport();
     228         [ #  # ]:          0 :         Reference<XMultiServiceFactory> xFactor(rImport.GetModel(),uno::UNO_QUERY);
     229 [ #  # ][ #  # ]:          0 :         Reference<XFixedLine> xFixedLine(xFactor->createInstance(SERVICE_FIXEDLINE),uno::UNO_QUERY);
         [ #  # ][ #  # ]
     230 [ #  # ][ #  # ]:          0 :         m_xComponent = xFixedLine.get();
     231 [ #  # ][ #  # ]:          0 :         m_pContainer->getSection()->add(m_xComponent.get());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     232         [ #  # ]:          0 :         m_pContainer->addCell(m_xComponent);
     233 [ #  # ][ #  # ]:          0 :         XMLPropStyleContext* pAutoStyle = PTR_CAST(XMLPropStyleContext,GetImport().GetAutoStyles()->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_CELL,m_sStyleName));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     234         [ #  # ]:          0 :         if ( pAutoStyle )
     235                 :            :         {
     236         [ #  # ]:          0 :             uno::Reference<beans::XPropertySet> xBorderProp = OXMLHelper::createBorderPropertySet();
     237                 :            :             try
     238                 :            :             {
     239         [ #  # ]:          0 :                 pAutoStyle->FillPropertySet(xBorderProp);
     240                 :          0 :                 table::BorderLine aRight,aLeft;
     241 [ #  # ][ #  # ]:          0 :                 xBorderProp->getPropertyValue(PROPERTY_BORDERRIGHT) >>= aRight;
         [ #  # ][ #  # ]
     242 [ #  # ][ #  # ]:          0 :                 xBorderProp->getPropertyValue(PROPERTY_BORDERLEFT) >>= aLeft;
         [ #  # ][ #  # ]
                 [ #  # ]
     243 [ #  # ][ #  # ]:          0 :                 xFixedLine->setOrientation( (aRight.OuterLineWidth != 0 || aLeft.OuterLineWidth != 0) ? 1 : 0);
         [ #  # ][ #  # ]
     244                 :            :                }
     245         [ #  # ]:          0 :             catch(uno::Exception&)
     246                 :            :             {
     247                 :            :                 OSL_FAIL("OXMLCell::EndElement -> exception catched");
     248                 :          0 :             }
     249                 :          0 :         }
     250                 :            :     }
     251                 :            :     else
     252 [ #  # ][ #  # ]:          0 :         OXMLHelper::copyStyleElements(GetOwnImport().isOldFormat(),m_sStyleName,GetImport().GetAutoStyles(),m_xComponent.get());
         [ #  # ][ #  # ]
     253                 :          0 : }
     254                 :            : // -----------------------------------------------------------------------------
     255                 :          0 : ORptFilter& OXMLCell::GetOwnImport()
     256                 :            : {
     257                 :          0 :     return static_cast<ORptFilter&>(GetImport());
     258                 :            : }
     259                 :            : // -----------------------------------------------------------------------------
     260                 :          0 : void OXMLCell::setComponent(const uno::Reference< report::XReportComponent >& _xComponent)
     261                 :            : {
     262                 :          0 :     m_pCell->m_xComponent = _xComponent;
     263                 :          0 :     m_xComponent = _xComponent;
     264                 :          0 : }
     265                 :            : // -----------------------------------------------------------------------------
     266                 :          0 : void OXMLCell::Characters( const ::rtl::OUString& rChars )
     267                 :            : {
     268         [ #  # ]:          0 :     if ( !rChars.isEmpty() )
     269                 :            :     {
     270 [ #  # ][ #  # ]:          0 :         static const ::rtl::OUString s_Quote(RTL_CONSTASCII_USTRINGPARAM("\""));
         [ #  # ][ #  # ]
     271         [ #  # ]:          0 :         if ( !m_sText.isEmpty() )
     272                 :            :         {
     273 [ #  # ][ #  # ]:          0 :             static const ::rtl::OUString s_sStringConcat(RTL_CONSTASCII_USTRINGPARAM(" & "));
         [ #  # ][ #  # ]
     274                 :          0 :             m_sText += s_sStringConcat;
     275                 :            :         }
     276                 :            : 
     277                 :          0 :         m_sText += s_Quote + rChars + s_Quote;
     278                 :            :     }
     279                 :          0 : }
     280                 :            : 
     281                 :          0 : void OXMLCell::setContainsShape(bool _bContainsShape)
     282                 :            : {
     283                 :          0 :     m_bContainsShape = _bContainsShape;
     284                 :          0 : }
     285                 :            : 
     286                 :            : //----------------------------------------------------------------------------
     287                 :            : } // namespace rptxml
     288                 :            : // -----------------------------------------------------------------------------
     289                 :            : 
     290                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10