LCOV - code coverage report
Current view: top level - writerfilter/source/dmapper - TblStylePrHandler.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 104 109 95.4 %
Date: 2014-11-03 Functions: 11 11 100.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 <TblStylePrHandler.hxx>
      21             : #include <PropertyMap.hxx>
      22             : #include <ooxml/resourceids.hxx>
      23             : #include <resourcemodel/QNameToString.hxx>
      24             : 
      25             : #include "dmapperLoggers.hxx"
      26             : 
      27             : using namespace css;
      28             : 
      29             : namespace writerfilter {
      30             : namespace dmapper {
      31             : 
      32       10784 : TblStylePrHandler::TblStylePrHandler( DomainMapper & rDMapper ) :
      33             : LoggedProperties(dmapper_logger, "TblStylePrHandler"),
      34             : m_rDMapper( rDMapper ),
      35       10784 : m_pTablePropsHandler( new TablePropertiesHandler( true ) ),
      36             : m_nType( TBL_STYLE_UNKNOWN ),
      37       21568 : m_pProperties( new PropertyMap )
      38             : {
      39       10784 : }
      40             : 
      41       32352 : TblStylePrHandler::~TblStylePrHandler( )
      42             : {
      43       10784 :     delete m_pTablePropsHandler, m_pTablePropsHandler = nullptr;
      44       21568 : }
      45             : 
      46        5172 : OUString TblStylePrHandler::getTypeString()
      47             : {
      48        5172 :     switch (m_nType)
      49             :     {
      50           0 :         case TBL_STYLE_WHOLETABLE: return OUString("wholeTable");
      51        1282 :         case TBL_STYLE_FIRSTROW: return OUString("firstRow");
      52         750 :         case TBL_STYLE_LASTROW: return OUString("lastRow");
      53         692 :         case TBL_STYLE_FIRSTCOL: return OUString("firstCol");
      54         614 :         case TBL_STYLE_LASTCOL: return OUString("lastCol");
      55         284 :         case TBL_STYLE_BAND1VERT: return OUString("band1Vert");
      56         152 :         case TBL_STYLE_BAND2VERT: return OUString("band2Vert");
      57         362 :         case TBL_STYLE_BAND1HORZ: return OUString("band1Horz");
      58         138 :         case TBL_STYLE_BAND2HORZ: return OUString("band2Horz");
      59         234 :         case TBL_STYLE_NECELL: return OUString("neCell");
      60         232 :         case TBL_STYLE_NWCELL: return OUString("nwCell");
      61          54 :         case TBL_STYLE_SECELL: return OUString("seCell");
      62         378 :         case TBL_STYLE_SWCELL: return OUString("swCell");
      63           0 :         default: break;
      64             :     }
      65           0 :     return OUString();
      66             : }
      67             : 
      68        5172 : void TblStylePrHandler::lcl_attribute(Id rName, Value & rVal)
      69             : {
      70             : #ifdef DEBUG_WRITERFILTER
      71             :     dmapper_logger->startElement("TblStylePrHandler.attribute");
      72             :     dmapper_logger->attribute("name", (*QNameToString::Instance())(rName));
      73             :     dmapper_logger->chars(rVal.toString());
      74             :     dmapper_logger->endElement();
      75             : #endif
      76             : 
      77        5172 :     switch ( rName )
      78             :     {
      79             :         case NS_ooxml::LN_CT_TblStyleOverrideType:
      80             :             {
      81        5172 :                 switch (rVal.getInt())
      82             :                 {
      83             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_wholeTable:
      84           0 :                     m_nType = TBL_STYLE_WHOLETABLE;
      85           0 :                     break;
      86             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_firstRow:
      87        1282 :                     m_nType = TBL_STYLE_FIRSTROW;
      88        1282 :                     break;
      89             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_lastRow:
      90         750 :                     m_nType = TBL_STYLE_LASTROW;
      91         750 :                     break;
      92             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_firstCol:
      93         692 :                     m_nType = TBL_STYLE_FIRSTCOL;
      94         692 :                     break;
      95             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_lastCol:
      96         614 :                     m_nType = TBL_STYLE_LASTCOL;
      97         614 :                     break;
      98             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_band1Vert:
      99         284 :                     m_nType = TBL_STYLE_BAND1VERT;
     100         284 :                     break;
     101             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_band2Vert:
     102         152 :                     m_nType = TBL_STYLE_BAND2VERT;
     103         152 :                     break;
     104             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_band1Horz:
     105         362 :                     m_nType = TBL_STYLE_BAND1HORZ;
     106         362 :                     break;
     107             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_band2Horz:
     108         138 :                     m_nType = TBL_STYLE_BAND2HORZ;
     109         138 :                     break;
     110             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_neCell:
     111         234 :                     m_nType = TBL_STYLE_NECELL;
     112         234 :                     break;
     113             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_nwCell:
     114         232 :                     m_nType = TBL_STYLE_NWCELL;
     115         232 :                     break;
     116             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_seCell:
     117          54 :                     m_nType = TBL_STYLE_SECELL;
     118          54 :                     break;
     119             :                 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_swCell:
     120         378 :                     m_nType = TBL_STYLE_SWCELL;
     121         378 :                     break;
     122             :                 }
     123             :             }
     124        5172 :             break;
     125             :     }
     126        5172 : }
     127             : 
     128       42072 : void TblStylePrHandler::lcl_sprm(Sprm & rSprm)
     129             : {
     130             : #ifdef DEBUG_WRITERFILTER
     131             :     dmapper_logger->startElement("TblStylePrHandler.sprm");
     132             :     dmapper_logger->attribute("sprm", rSprm.toString());
     133             : #endif
     134             : 
     135       42072 :     Value::Pointer_t pValue = rSprm.getValue();
     136       42072 :     switch ( rSprm.getId( ) )
     137             :     {
     138             :         case NS_ooxml::LN_CT_PPrBase:
     139             :         case NS_ooxml::LN_EG_RPrBase:
     140             :         case NS_ooxml::LN_CT_TblPrBase:
     141             :         case NS_ooxml::LN_CT_TrPrBase:
     142             :         case NS_ooxml::LN_CT_TcPrBase:
     143             :         {
     144       13776 :             comphelper::SequenceAsVector<beans::PropertyValue> aSavedGrabBag;
     145       27180 :             bool bGrabBag = rSprm.getId() == NS_ooxml::LN_CT_PPrBase ||
     146       23088 :                 rSprm.getId() == NS_ooxml::LN_EG_RPrBase ||
     147       28290 :                 rSprm.getId() == NS_ooxml::LN_CT_TblPrBase ||
     148       18606 :                 rSprm.getId() == NS_ooxml::LN_CT_TcPrBase;
     149       13776 :             if (bGrabBag)
     150             :             {
     151       13696 :                 aSavedGrabBag = m_aInteropGrabBag;
     152       13696 :                 m_aInteropGrabBag.clear();
     153             :             }
     154       13776 :             resolveSprmProps( rSprm );
     155       13776 :             if (bGrabBag)
     156             :             {
     157       13696 :                 if (rSprm.getId() == NS_ooxml::LN_CT_PPrBase)
     158         372 :                     aSavedGrabBag.push_back(getInteropGrabBag("pPr"));
     159       13324 :                 else if (rSprm.getId() == NS_ooxml::LN_EG_RPrBase)
     160        3720 :                     aSavedGrabBag.push_back(getInteropGrabBag("rPr"));
     161        9604 :                 else if (rSprm.getId() == NS_ooxml::LN_CT_TblPrBase)
     162        4854 :                     aSavedGrabBag.push_back(getInteropGrabBag("tblPr"));
     163        4750 :                 else if (rSprm.getId() == NS_ooxml::LN_CT_TcPrBase)
     164        4750 :                     aSavedGrabBag.push_back(getInteropGrabBag("tcPr"));
     165       13696 :                 m_aInteropGrabBag = aSavedGrabBag;
     166       13776 :             }
     167             :         }
     168       13776 :             break;
     169             :         default:
     170             :             // Tables specific properties have to handled here
     171       28296 :             m_pTablePropsHandler->SetProperties( m_pProperties );
     172       28296 :             m_pTablePropsHandler->SetInteropGrabBag(m_aInteropGrabBag);
     173       28296 :             bool bRet = m_pTablePropsHandler->sprm( rSprm );
     174             : 
     175       28296 :             if ( !bRet )
     176             :             {
     177             :                 // The DomainMapper can handle some of the properties
     178        9778 :                 m_rDMapper.PushStyleSheetProperties( m_pProperties, true );
     179             :                 // Just pass a non-empty string, the array will have a single element anyway.
     180        9778 :                 m_rDMapper.enableInteropGrabBag("TblStylePrHandler");
     181        9778 :                 m_rDMapper.sprm( rSprm );
     182        9778 :                 uno::Sequence<beans::PropertyValue> aGrabBag = m_rDMapper.getInteropGrabBag().Value.get< uno::Sequence<beans::PropertyValue> >();
     183        9778 :                 if (aGrabBag.hasElements())
     184        8630 :                     m_aInteropGrabBag.push_back(aGrabBag[0]);
     185        9778 :                 m_rDMapper.PopStyleSheetProperties( true );
     186             :             }
     187       42072 :     }
     188             : 
     189             : #ifdef DEBUG_WRITERFILTER
     190             :     dmapper_logger->endElement();
     191             : #endif
     192       42072 : }
     193             : 
     194       13776 : void TblStylePrHandler::resolveSprmProps(Sprm & rSprm)
     195             : {
     196       13776 :     writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
     197       13776 :     if( pProperties.get())
     198       13776 :         pProperties->resolve(*this);
     199       13776 : }
     200             : 
     201        5172 : void TblStylePrHandler::appendInteropGrabBag(const OUString& aKey, const OUString& aValue)
     202             : {
     203        5172 :     beans::PropertyValue aProperty;
     204        5172 :     aProperty.Name = aKey;
     205        5172 :     aProperty.Value = uno::makeAny(aValue);
     206        5172 :     m_aInteropGrabBag.push_back(aProperty);
     207        5172 : }
     208             : 
     209       24480 : beans::PropertyValue TblStylePrHandler::getInteropGrabBag(const OUString& aName)
     210             : {
     211       24480 :     beans::PropertyValue aRet;
     212       24480 :     aRet.Name = aName;
     213             : 
     214       24480 :     aRet.Value = uno::makeAny(m_aInteropGrabBag.getAsConstList());
     215       24480 :     return aRet;
     216             : }
     217             : 
     218         114 : }}
     219             : 
     220             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10