LCOV - code coverage report
Current view: top level - writerfilter/source/dmapper - PageBordersHandler.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 53 59 89.8 %
Date: 2014-04-11 Functions: 8 8 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 "PageBordersHandler.hxx"
      21             : 
      22             : #include <ooxml/resourceids.hxx>
      23             : 
      24             : #include "dmapperLoggers.hxx"
      25             : 
      26             : namespace writerfilter {
      27             : namespace dmapper {
      28             : 
      29          60 : _PgBorder::_PgBorder( ) :
      30             :     m_nDistance( 0 ),
      31             :     m_ePos( BORDER_RIGHT ),
      32          60 :     m_bShadow(false)
      33             : {
      34          60 : }
      35             : 
      36         225 : _PgBorder::~_PgBorder( )
      37             : {
      38         225 : }
      39             : 
      40          15 : PageBordersHandler::PageBordersHandler( ) :
      41             : LoggedProperties(dmapper_logger, "PageBordersHandler"),
      42             : m_nDisplay( 0 ),
      43          15 : m_nOffset( 0 )
      44             : {
      45          15 : }
      46             : 
      47          30 : PageBordersHandler::~PageBordersHandler( )
      48             : {
      49          30 : }
      50             : 
      51          19 : void PageBordersHandler::lcl_attribute( Id eName, Value& rVal )
      52             : {
      53          19 :     int nIntValue = rVal.getInt( );
      54          19 :     switch ( eName )
      55             :     {
      56             :         case NS_ooxml::LN_CT_PageBorders_display:
      57             :         {
      58           4 :             switch ( nIntValue )
      59             :             {
      60             :                 default:
      61             :                 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_allPages:
      62           4 :                     m_nDisplay = 0;
      63           4 :                     break;
      64             :                 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_firstPage:
      65           0 :                     m_nDisplay = 1;
      66           0 :                     break;
      67             :                 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderDisplay_notFirstPage:
      68           0 :                     m_nDisplay = 2;
      69           0 :                     break;
      70             :             }
      71             :         }
      72           4 :         break;
      73             :         case NS_ooxml::LN_CT_PageBorders_offsetFrom:
      74             :         {
      75          15 :             switch ( nIntValue )
      76             :             {
      77             :                 default:
      78             :                 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_page:
      79          15 :                     m_nOffset = 1;
      80          15 :                     break;
      81             :                 case NS_ooxml::LN_Value_wordprocessingml_ST_PageBorderOffset_text:
      82           0 :                     m_nOffset = 0;
      83           0 :                     break;
      84             :             }
      85             :         }
      86          15 :         break;
      87             :         default:;
      88             :     }
      89          19 : }
      90             : 
      91          60 : void PageBordersHandler::lcl_sprm( Sprm& rSprm )
      92             : {
      93          60 :     switch ( rSprm.getId( ) )
      94             :     {
      95             :         case NS_ooxml::LN_CT_PageBorders_top:
      96             :         case NS_ooxml::LN_CT_PageBorders_left:
      97             :         case NS_ooxml::LN_CT_PageBorders_bottom:
      98             :         case NS_ooxml::LN_CT_PageBorders_right:
      99             :         {
     100          60 :             writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
     101          60 :             if( pProperties.get())
     102             :             {
     103          60 :                 BorderHandlerPtr pBorderHandler( new BorderHandler( true ) );
     104          60 :                 pProperties->resolve(*pBorderHandler);
     105          60 :                 BorderPosition ePos = BorderPosition( 0 );
     106          60 :                 switch( rSprm.getId( ) )
     107             :                 {
     108             :                     case NS_ooxml::LN_CT_PageBorders_top:
     109          15 :                         ePos = BORDER_TOP;
     110          15 :                     break;
     111             :                     case NS_ooxml::LN_CT_PageBorders_left:
     112          15 :                         ePos = BORDER_LEFT;
     113          15 :                     break;
     114             :                     case NS_ooxml::LN_CT_PageBorders_bottom:
     115          15 :                         ePos = BORDER_BOTTOM;
     116          15 :                     break;
     117             :                     case NS_ooxml::LN_CT_PageBorders_right:
     118          15 :                         ePos = BORDER_RIGHT;
     119          15 :                     break;
     120             :                     default:;
     121             :                 }
     122             : 
     123          60 :                 _PgBorder aPgBorder;
     124          60 :                 aPgBorder.m_rLine = pBorderHandler->getBorderLine( );
     125          60 :                 aPgBorder.m_nDistance = pBorderHandler->getLineDistance( );
     126          60 :                 aPgBorder.m_ePos = ePos;
     127          60 :                 aPgBorder.m_bShadow = pBorderHandler->getShadow();
     128          60 :                 m_aBorders.push_back( aPgBorder );
     129          60 :             }
     130             :         }
     131          60 :         break;
     132             :         default:;
     133             :     }
     134          60 : }
     135             : 
     136          15 : void PageBordersHandler::SetBorders( SectionPropertyMap* pSectContext )
     137             : {
     138          75 :     for ( int i = 0, length = m_aBorders.size( ); i < length; i++ )
     139             :     {
     140          60 :         _PgBorder aBorder = m_aBorders[i];
     141          60 :         pSectContext->SetBorder( aBorder.m_ePos, aBorder.m_nDistance, aBorder.m_rLine, aBorder.m_bShadow );
     142          60 :     }
     143          15 : }
     144             : 
     145             : } }
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10