LCOV - code coverage report
Current view: top level - writerfilter/source/dmapper - TblStylePrHandler.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 87 0.0 %
Date: 2014-04-14 Functions: 0 11 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 <TblStylePrHandler.hxx>
      21             : #include <PropertyMap.hxx>
      22             : #include <ooxml/resourceids.hxx>
      23             : #include <dmapperLoggers.hxx>
      24             : #include <resourcemodel/QNameToString.hxx>
      25             : 
      26             : #include "dmapperLoggers.hxx"
      27             : 
      28             : namespace writerfilter {
      29             : namespace dmapper {
      30             : 
      31           0 : TblStylePrHandler::TblStylePrHandler( DomainMapper & rDMapper ) :
      32             : LoggedProperties(dmapper_logger, "TblStylePrHandler"),
      33             : m_rDMapper( rDMapper ),
      34           0 : m_pTablePropsHandler( new TablePropertiesHandler( true ) ),
      35             : m_nType( TBL_STYLE_UNKNOWN ),
      36           0 : m_pProperties( new PropertyMap )
      37             : {
      38           0 : }
      39             : 
      40           0 : TblStylePrHandler::~TblStylePrHandler( )
      41             : {
      42           0 :     delete m_pTablePropsHandler, m_pTablePropsHandler = NULL;
      43           0 : }
      44             : 
      45           0 : OUString TblStylePrHandler::getTypeString()
      46             : {
      47           0 :     switch (m_nType)
      48             :     {
      49           0 :         case TBL_STYLE_WHOLETABLE: return OUString("wholeTable");
      50           0 :         case TBL_STYLE_FIRSTROW: return OUString("firstRow");
      51           0 :         case TBL_STYLE_LASTROW: return OUString("lastRow");
      52           0 :         case TBL_STYLE_FIRSTCOL: return OUString("firstCol");
      53           0 :         case TBL_STYLE_LASTCOL: return OUString("lastCol");
      54           0 :         case TBL_STYLE_BAND1VERT: return OUString("band1Vert");
      55           0 :         case TBL_STYLE_BAND2VERT: return OUString("band2Vert");
      56           0 :         case TBL_STYLE_BAND1HORZ: return OUString("band1Horz");
      57           0 :         case TBL_STYLE_BAND2HORZ: return OUString("band2Horz");
      58           0 :         case TBL_STYLE_NECELL: return OUString("neCell");
      59           0 :         case TBL_STYLE_NWCELL: return OUString("nwCell");
      60           0 :         case TBL_STYLE_SECELL: return OUString("seCell");
      61           0 :         case TBL_STYLE_SWCELL: return OUString("swCell");
      62           0 :         default: break;
      63             :     }
      64           0 :     return OUString();
      65             : }
      66             : 
      67           0 : void TblStylePrHandler::lcl_attribute(Id rName, Value & rVal)
      68             : {
      69             : #ifdef DEBUG_DOMAINMAPPER
      70             :     dmapper_logger->startElement("TblStylePrHandler.attribute");
      71             :     dmapper_logger->attribute("name", (*QNameToString::Instance())(rName));
      72             :     dmapper_logger->chars(rVal.toString());
      73             :     dmapper_logger->endElement();
      74             : #endif
      75             : 
      76           0 :     switch ( rName )
      77             :     {
      78             :         case NS_ooxml::LN_CT_TblStyleOverrideType:
      79             :             {
      80             :                 // The tokenid should be the same in the model.xml than
      81             :                 // in the TblStyleType enum
      82           0 :                 m_nType = TblStyleType( rVal.getInt( ) );
      83             :             }
      84           0 :             break;
      85             :     }
      86           0 : }
      87             : 
      88           0 : void TblStylePrHandler::lcl_sprm(Sprm & rSprm)
      89             : {
      90             : #ifdef DEBUG_DOMAINMAPPER
      91             :     dmapper_logger->startElement("TblStylePrHandler.sprm");
      92             :     dmapper_logger->attribute("sprm", rSprm.toString());
      93             : #endif
      94             : 
      95           0 :     Value::Pointer_t pValue = rSprm.getValue();
      96           0 :     switch ( rSprm.getId( ) )
      97             :     {
      98             :         case NS_ooxml::LN_CT_PPrBase:
      99             :         case NS_ooxml::LN_EG_RPrBase:
     100             :         case NS_ooxml::LN_CT_TblPrBase:
     101             :         case NS_ooxml::LN_CT_TrPrBase:
     102             :         case NS_ooxml::LN_CT_TcPrBase:
     103             :         {
     104           0 :             std::vector<beans::PropertyValue> aSavedGrabBag;
     105           0 :             bool bGrabBag = rSprm.getId() == NS_ooxml::LN_CT_PPrBase ||
     106           0 :                 rSprm.getId() == NS_ooxml::LN_EG_RPrBase ||
     107           0 :                 rSprm.getId() == NS_ooxml::LN_CT_TblPrBase ||
     108           0 :                 rSprm.getId() == NS_ooxml::LN_CT_TcPrBase;
     109           0 :             if (bGrabBag)
     110             :             {
     111           0 :                 aSavedGrabBag = m_aInteropGrabBag;
     112           0 :                 m_aInteropGrabBag.clear();
     113             :             }
     114           0 :             resolveSprmProps( rSprm );
     115           0 :             if (bGrabBag)
     116             :             {
     117           0 :                 if (rSprm.getId() == NS_ooxml::LN_CT_PPrBase)
     118           0 :                     aSavedGrabBag.push_back(getInteropGrabBag("pPr"));
     119           0 :                 else if (rSprm.getId() == NS_ooxml::LN_EG_RPrBase)
     120           0 :                     aSavedGrabBag.push_back(getInteropGrabBag("rPr"));
     121           0 :                 else if (rSprm.getId() == NS_ooxml::LN_CT_TblPrBase)
     122           0 :                     aSavedGrabBag.push_back(getInteropGrabBag("tblPr"));
     123           0 :                 else if (rSprm.getId() == NS_ooxml::LN_CT_TcPrBase)
     124           0 :                     aSavedGrabBag.push_back(getInteropGrabBag("tcPr"));
     125           0 :                 m_aInteropGrabBag = aSavedGrabBag;
     126           0 :             }
     127             :         }
     128           0 :             break;
     129             :         default:
     130             :             // Tables specific properties have to handled here
     131           0 :             m_pTablePropsHandler->SetProperties( m_pProperties );
     132           0 :             m_pTablePropsHandler->SetInteropGrabBag(m_aInteropGrabBag);
     133           0 :             bool bRet = m_pTablePropsHandler->sprm( rSprm );
     134             : 
     135           0 :             if ( !bRet )
     136             :             {
     137             :                 // The DomainMapper can handle some of the properties
     138           0 :                 m_rDMapper.PushStyleSheetProperties( m_pProperties, true );
     139             :                 // Just pass a non-empty string, the array will have a single element anyway.
     140           0 :                 m_rDMapper.enableInteropGrabBag("TblStylePrHandler");
     141           0 :                 m_rDMapper.sprm( rSprm );
     142           0 :                 uno::Sequence<beans::PropertyValue> aGrabBag = m_rDMapper.getInteropGrabBag().Value.get< uno::Sequence<beans::PropertyValue> >();
     143           0 :                 if (aGrabBag.hasElements())
     144           0 :                     m_aInteropGrabBag.push_back(aGrabBag[0]);
     145           0 :                 m_rDMapper.PopStyleSheetProperties( true );
     146             :             }
     147           0 :     }
     148             : 
     149             : #ifdef DEBUG_DOMAINMAPPER
     150             :     dmapper_logger->endElement();
     151             : #endif
     152           0 : }
     153             : 
     154           0 : void TblStylePrHandler::resolveSprmProps(Sprm & rSprm)
     155             : {
     156           0 :     writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
     157           0 :     if( pProperties.get())
     158           0 :         pProperties->resolve(*this);
     159           0 : }
     160             : 
     161           0 : void TblStylePrHandler::appendInteropGrabBag(const OUString& aKey, const OUString& aValue)
     162             : {
     163           0 :     beans::PropertyValue aProperty;
     164           0 :     aProperty.Name = aKey;
     165           0 :     aProperty.Value = uno::makeAny(aValue);
     166           0 :     m_aInteropGrabBag.push_back(aProperty);
     167           0 : }
     168             : 
     169           0 : beans::PropertyValue TblStylePrHandler::getInteropGrabBag(const OUString& aName)
     170             : {
     171           0 :     beans::PropertyValue aRet;
     172           0 :     aRet.Name = aName;
     173             : 
     174           0 :     uno::Sequence<beans::PropertyValue> aSeq(m_aInteropGrabBag.size());
     175           0 :     beans::PropertyValue* pSeq = aSeq.getArray();
     176           0 :     for (std::vector<beans::PropertyValue>::iterator i = m_aInteropGrabBag.begin(); i != m_aInteropGrabBag.end(); ++i)
     177           0 :         *pSeq++ = *i;
     178             : 
     179           0 :     aRet.Value = uno::makeAny(aSeq);
     180           0 :     return aRet;
     181             : }
     182             : 
     183           0 : }}
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10