LCOV - code coverage report
Current view: top level - libreoffice/writerfilter/source/dmapper - CellMarginHandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 41 45 91.1 %
Date: 2012-12-17 Functions: 7 7 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             : #include <CellMarginHandler.hxx>
      20             : #include <PropertyMap.hxx>
      21             : #include <doctok/resourceids.hxx>
      22             : #include <ConversionHelper.hxx>
      23             : #include <ooxml/resourceids.hxx>
      24             : #include "dmapperLoggers.hxx"
      25             : 
      26             : namespace writerfilter {
      27             : namespace dmapper {
      28             : 
      29             : using namespace ::com::sun::star;
      30             : using namespace ::writerfilter;
      31             : 
      32         188 : CellMarginHandler::CellMarginHandler() :
      33             : LoggedProperties(dmapper_logger, "CellMarginHandler"),
      34             : m_nValue( 0 ),
      35             : m_nLeftMargin( 0 ),
      36             : m_bLeftMarginValid( false ),
      37             : m_nRightMargin( 0 ),
      38             : m_bRightMarginValid( false ),
      39             : m_nTopMargin( 0 ),
      40             : m_bTopMarginValid( false ),
      41             : m_nBottomMargin( 0 ),
      42         188 : m_bBottomMarginValid( false )
      43             : {
      44         188 : }
      45             : 
      46         376 : CellMarginHandler::~CellMarginHandler()
      47             : {
      48         376 : }
      49             : 
      50        1240 : void CellMarginHandler::lcl_attribute(Id rName, Value & rVal)
      51             : {
      52        1240 :     sal_Int32 nIntValue = rVal.getInt();
      53             :     (void)nIntValue;
      54             :     (void)rName;
      55        1240 :     switch( rName )
      56             :     {
      57             :         case NS_ooxml::LN_CT_TblWidth_w:
      58         620 :             m_nValue = ConversionHelper::convertTwipToMM100( nIntValue );
      59         620 :         break;
      60             :         case NS_ooxml::LN_CT_TblWidth_type:
      61             :             OSL_ENSURE( NS_ooxml::LN_Value_ST_TblWidth_dxa == sal::static_int_cast<Id>(nIntValue), "cell margins work for absolute values, only");
      62         620 :         break;
      63             :         default:
      64             :             OSL_FAIL( "unknown attribute");
      65             :     }
      66        1240 : }
      67             : 
      68         620 : void CellMarginHandler::lcl_sprm(Sprm & rSprm)
      69             : {
      70         620 :     writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
      71         620 :     if( pProperties.get())
      72             :     {
      73         620 :         pProperties.get()->resolve( *this );
      74         620 :         bool rtl = false; // TODO
      75         620 :         switch( rSprm.getId() )
      76             :         {
      77             :             case NS_ooxml::LN_CT_TblCellMar_top:
      78         126 :                 m_nTopMargin = m_nValue;
      79         126 :                 m_bTopMarginValid = true;
      80         126 :             break;
      81             :             case NS_ooxml::LN_CT_TblCellMar_start:
      82          10 :                 if( rtl )
      83             :                 {
      84           0 :                     m_nRightMargin = m_nValue;
      85           0 :                     m_bRightMarginValid = true;
      86             :                 }
      87             :                 else
      88             :                 {
      89          10 :                     m_nLeftMargin = m_nValue;
      90          10 :                     m_bLeftMarginValid = true;
      91             :                 }
      92          10 :             break;
      93             :             case NS_ooxml::LN_CT_TblCellMar_left:
      94         178 :                 m_nLeftMargin = m_nValue;
      95         178 :                 m_bLeftMarginValid = true;
      96         178 :             break;
      97             :             case NS_ooxml::LN_CT_TblCellMar_bottom:
      98         126 :                 m_nBottomMargin = m_nValue;
      99         126 :                 m_bBottomMarginValid = true;
     100         126 :             break;
     101             :             case NS_ooxml::LN_CT_TblCellMar_end:
     102          10 :                 if( rtl )
     103             :                 {
     104           0 :                     m_nLeftMargin = m_nValue;
     105           0 :                     m_bLeftMarginValid = true;
     106             :                 }
     107             :                 else
     108             :                 {
     109          10 :                     m_nRightMargin = m_nValue;
     110          10 :                     m_bRightMarginValid = true;
     111             :                 }
     112          10 :             break;
     113             :             case NS_ooxml::LN_CT_TblCellMar_right:
     114         170 :                 m_nRightMargin = m_nValue;
     115         170 :                 m_bRightMarginValid = true;
     116         170 :             break;
     117             :             default:
     118             :                 OSL_FAIL( "unknown attribute");
     119             :         }
     120             :     }
     121         620 :     m_nValue = 0;
     122         620 : }
     123             : } //namespace dmapper
     124          30 : } //namespace writerfilter
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10