LCOV - code coverage report
Current view: top level - writerfilter/source/dmapper - MeasureHandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 28 30 93.3 %
Date: 2012-08-25 Functions: 7 8 87.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 22 35 62.9 %

           Branch data     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 <MeasureHandler.hxx>
      20                 :            : #include <PropertyMap.hxx>
      21                 :            : #include <doctok/resourceids.hxx>
      22                 :            : #include <ConversionHelper.hxx>
      23                 :            : #include <ooxml/resourceids.hxx>
      24                 :            : #include <com/sun/star/text/SizeType.hpp>
      25                 :            : #include "dmapperLoggers.hxx"
      26                 :            : 
      27                 :            : namespace writerfilter {
      28                 :            : namespace dmapper {
      29                 :            : 
      30                 :            : using namespace ::com::sun::star;
      31                 :            : 
      32                 :            : 
      33                 :            : 
      34                 :        207 : MeasureHandler::MeasureHandler() :
      35                 :            : LoggedProperties(dmapper_logger, "MeasureHandler"),
      36                 :            : m_nMeasureValue( 0 ),
      37                 :            : m_nUnit( -1 ),
      38 [ +  - ][ +  - ]:        207 : m_nRowHeightSizeType( text::SizeType::MIN )
         [ +  - ][ +  - ]
      39                 :            : {
      40                 :        207 : }
      41                 :            : 
      42                 :            : 
      43                 :        207 : MeasureHandler::~MeasureHandler()
      44                 :            : {
      45         [ -  + ]:        414 : }
      46                 :            : 
      47                 :            : 
      48                 :        411 : void MeasureHandler::lcl_attribute(Id rName, Value & rVal)
      49                 :            : {
      50                 :        411 :     sal_Int32 nIntValue = rVal.getInt();
      51                 :            :     (void)rName;
      52   [ +  +  +  +  :        411 :     switch( rName )
                      - ]
      53                 :            :     {
      54                 :            :         case NS_rtf::LN_unit:
      55                 :            :         case NS_ooxml::LN_CT_TblWidth_type:// = 90668;
      56                 :            :             //can be: NS_ooxml::LN_Value_ST_TblWidth_nil, NS_ooxml::LN_Value_ST_TblWidth_pct,
      57                 :            :             //        NS_ooxml::LN_Value_ST_TblWidth_dxa, NS_ooxml::LN_Value_ST_TblWidth_auto;
      58                 :        196 :             m_nUnit = nIntValue;
      59                 :        196 :         break;
      60                 :            :         case NS_ooxml::LN_CT_Height_hRule: // 90666;
      61                 :            :         {
      62         [ +  - ]:          8 :             OUString sHeightType = rVal.getString();
      63         [ +  + ]:          8 :             if ( sHeightType == "exact" )
      64                 :          8 :                 m_nRowHeightSizeType = text::SizeType::FIX;
      65                 :            :         }
      66                 :          8 :         break;
      67                 :            :         case NS_rtf::LN_trleft:
      68                 :            :         case NS_rtf::LN_preferredWidth:
      69                 :            :         case NS_ooxml::LN_CT_TblWidth_w:// = 90667;
      70                 :        196 :             m_nMeasureValue = nIntValue;
      71                 :        196 :         break;
      72                 :            :         case NS_ooxml::LN_CT_Height_val: // 90665 -- a string value
      73                 :            :         {
      74                 :         11 :             m_nUnit = NS_ooxml::LN_Value_ST_TblWidth_dxa;
      75         [ +  - ]:         11 :             OUString sHeight = rVal.getString();
      76                 :         11 :             m_nMeasureValue = sHeight.toInt32();
      77                 :            :         }
      78                 :         11 :         break;
      79                 :            :         default:
      80                 :            :             OSL_FAIL( "unknown attribute");
      81                 :            :     }
      82                 :        411 : }
      83                 :            : 
      84                 :            : 
      85                 :          0 : void MeasureHandler::lcl_sprm(Sprm & rSprm)
      86                 :            : {
      87                 :            :     (void)rSprm;
      88                 :          0 : }
      89                 :            : 
      90                 :            : 
      91                 :        207 : sal_Int32 MeasureHandler::getMeasureValue() const
      92                 :            : {
      93                 :        207 :     sal_Int32 nRet = 0;
      94 [ +  + ][ +  - ]:        207 :     if( m_nMeasureValue != 0 && m_nUnit >= 0 )
      95                 :            :     {
      96                 :            :         // TODO m_nUnit 3 - twip, other values unknown :-(
      97 [ +  + ][ +  - ]:         81 :         if( m_nUnit == 3 || sal::static_int_cast<Id>(m_nUnit) == NS_ooxml::LN_Value_ST_TblWidth_dxa)
                 [ +  - ]
      98                 :            :         {
      99                 :         81 :             nRet = ConversionHelper::convertTwipToMM100( m_nMeasureValue );
     100                 :            :         }
     101                 :            :         //todo: handle additional width types:
     102                 :            :         //NS_ooxml::LN_Value_ST_TblWidth_nil, NS_ooxml::LN_Value_ST_TblWidth_pct,
     103                 :            :         //NS_ooxml::LN_Value_ST_TblWidth_dxa, NS_ooxml::LN_Value_ST_TblWidth_auto;
     104                 :            :     }
     105                 :        207 :     return nRet;
     106                 :            : }
     107                 :            : 
     108                 :            : } //namespace dmapper
     109 [ +  - ][ +  - ]:         60 : } //namespace writerfilter
     110                 :            : 
     111                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10