LCOV - code coverage report
Current view: top level - libreoffice/reportdesign/source/filter/xml - xmlColumn.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 69 0.0 %
Date: 2012-12-27 Functions: 0 7 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             : 
      20             : #include "xmlColumn.hxx"
      21             : #include <xmloff/xmluconv.hxx>
      22             : #include "xmlfilter.hxx"
      23             : #include <xmloff/xmltoken.hxx>
      24             : #include <xmloff/xmlnmspe.hxx>
      25             : #include <xmloff/nmspmap.hxx>
      26             : #include "xmlEnums.hxx"
      27             : #include "xmlCell.hxx"
      28             : #include <tools/debug.hxx>
      29             : #include "xmlStyleImport.hxx"
      30             : #include "xmlTable.hxx"
      31             : #include <comphelper/namecontainer.hxx>
      32             : #include <comphelper/genericpropertyset.hxx>
      33             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      34             : #include "xmlstrings.hrc"
      35             : 
      36             : #define PROPERTY_ID_WIDTH    1
      37             : #define PROPERTY_ID_HEIGHT   2
      38             : 
      39             : namespace rptxml
      40             : {
      41             :     using namespace ::comphelper;
      42             :     using namespace ::com::sun::star::uno;
      43             :     using namespace ::com::sun::star::beans;
      44             :     using namespace ::com::sun::star::xml::sax;
      45             : 
      46             : DBG_NAME( rpt_OXMLRowColumn )
      47             : 
      48           0 : OXMLRowColumn::OXMLRowColumn( ORptFilter& rImport
      49             :                 ,sal_uInt16 nPrfx
      50             :                 ,const ::rtl::OUString& _sLocalName
      51             :                 ,const Reference< XAttributeList > & _xAttrList
      52             :                 ,OXMLTable* _pContainer
      53             :                 ) :
      54             :     SvXMLImportContext( rImport, nPrfx, _sLocalName )
      55           0 :     ,m_pContainer(_pContainer)
      56             : {
      57             :     DBG_CTOR( rpt_OXMLRowColumn,NULL);
      58             : 
      59           0 :     const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
      60           0 :     const SvXMLTokenMap& rTokenMap = rImport.GetColumnTokenMap();
      61             : 
      62           0 :     const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
      63           0 :     for(sal_Int16 i = 0; i < nLength; ++i)
      64             :     {
      65           0 :      ::rtl::OUString sLocalName;
      66           0 :         const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
      67           0 :         const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
      68           0 :         const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
      69             : 
      70           0 :         switch( rTokenMap.Get( nPrefix, sLocalName ) )
      71             :         {
      72             :             case XML_TOK_COLUMN_STYLE_NAME:
      73           0 :                 fillStyle(sValue);
      74           0 :                 break;
      75             :             default:
      76           0 :                 break;
      77             :         }
      78           0 :     }
      79           0 : }
      80             : // -----------------------------------------------------------------------------
      81             : 
      82           0 : OXMLRowColumn::~OXMLRowColumn()
      83             : {
      84             :     DBG_DTOR( rpt_OXMLRowColumn,NULL);
      85           0 : }
      86             : // -----------------------------------------------------------------------------
      87           0 : SvXMLImportContext* OXMLRowColumn::CreateChildContext(
      88             :         sal_uInt16 nPrefix,
      89             :         const ::rtl::OUString& rLocalName,
      90             :         const Reference< XAttributeList > & xAttrList )
      91             : {
      92           0 :     SvXMLImportContext *pContext = 0;
      93           0 :     ORptFilter& rImport = GetOwnImport();
      94           0 :     const SvXMLTokenMap&    rTokenMap   = rImport.GetColumnTokenMap();
      95             : 
      96           0 :     switch( rTokenMap.Get( nPrefix, rLocalName ) )
      97             :     {
      98             :         case XML_TOK_COLUMN:
      99           0 :             rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     100           0 :             pContext = new OXMLRowColumn( rImport, nPrefix, rLocalName,xAttrList,m_pContainer);
     101           0 :             break;
     102             :         case XML_TOK_ROW:
     103           0 :             m_pContainer->incrementRowIndex();
     104           0 :             rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     105           0 :             pContext = new OXMLRowColumn( rImport, nPrefix, rLocalName,xAttrList,m_pContainer);
     106           0 :             break;
     107             :         case XML_TOK_CELL:
     108           0 :             m_pContainer->incrementColumnIndex();
     109           0 :             rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
     110           0 :             pContext = new OXMLCell( rImport, nPrefix, rLocalName,xAttrList,m_pContainer);
     111           0 :             break;
     112             :         case XML_TOK_COV_CELL:
     113           0 :             m_pContainer->incrementColumnIndex();
     114           0 :             m_pContainer->addCell(NULL);
     115           0 :             break;
     116             :         default:
     117           0 :             break;
     118             :     }
     119             : 
     120           0 :     if( !pContext )
     121           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     122             : 
     123           0 :     return pContext;
     124             : }
     125             : // -----------------------------------------------------------------------------
     126           0 : void OXMLRowColumn::fillStyle(const ::rtl::OUString& _sStyleName)
     127             : {
     128           0 :     if ( !_sStyleName.isEmpty() )
     129             :     {
     130           0 :         const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles();
     131           0 :         if ( pAutoStyles )
     132             :         {
     133           0 :             PropertySetInfo* pInfo = new PropertySetInfo();
     134             :             static PropertyMapEntry pMap[] =
     135             :             {
     136           0 :                 {PROPERTY_WIDTH.ascii,  static_cast<sal_uInt16>(PROPERTY_WIDTH.length),     PROPERTY_ID_WIDTH,          &::getCppuType(static_cast< sal_Int32* >( NULL ))       ,PropertyAttribute::BOUND,0},
     137           0 :                 {PROPERTY_HEIGHT.ascii, static_cast<sal_uInt16>(PROPERTY_HEIGHT.length),    PROPERTY_ID_HEIGHT,         &::getCppuType(static_cast< sal_Int32* >( NULL ))       ,PropertyAttribute::BOUND,0},
     138             :                 { NULL, 0, 0, NULL, 0, 0 }
     139           0 :             };
     140           0 :             pInfo->add(pMap);
     141           0 :             Reference<XPropertySet> xProp = GenericPropertySet_CreateInstance(pInfo);
     142           0 :             XMLPropStyleContext* pAutoStyle = PTR_CAST(XMLPropStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_COLUMN,_sStyleName));
     143           0 :             if ( pAutoStyle )
     144             :             {
     145           0 :                 pAutoStyle->FillPropertySet(xProp);
     146           0 :                 sal_Int32 nWidth = 0;
     147           0 :                 xProp->getPropertyValue(PROPERTY_WIDTH) >>= nWidth;
     148           0 :                 m_pContainer->addWidth(nWidth);
     149             :             }
     150             :             else
     151             :             {
     152           0 :                 pAutoStyle = PTR_CAST(XMLPropStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_ROW,_sStyleName));
     153           0 :                 if ( pAutoStyle )
     154             :                 {
     155           0 :                     pAutoStyle->FillPropertySet(xProp);
     156           0 :                     sal_Int32 nHeight = 0;
     157           0 :                     xProp->getPropertyValue(PROPERTY_HEIGHT) >>= nHeight;
     158           0 :                     m_pContainer->addHeight(nHeight);
     159             :                 }
     160           0 :             }
     161             :         }
     162             :     }
     163           0 : }
     164             : // -----------------------------------------------------------------------------
     165           0 : ORptFilter& OXMLRowColumn::GetOwnImport()
     166             : {
     167           0 :     return static_cast<ORptFilter&>(GetImport());
     168             : }
     169             : // -----------------------------------------------------------------------------
     170           0 : void OXMLRowColumn::EndElement()
     171             : {
     172           0 : }
     173             : //----------------------------------------------------------------------------
     174             : } // namespace rptxml
     175             : // -----------------------------------------------------------------------------
     176             : 
     177             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10