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

Generated by: LCOV version 1.11