LCOV - code coverage report
Current view: top level - sw/source/filter/writer - wrt_fn.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 29 52 55.8 %
Date: 2014-11-03 Functions: 5 5 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 <svl/itemiter.hxx>
      21             : #include <svl/whiter.hxx>
      22             : 
      23             : #include "shellio.hxx"
      24             : #include "wrt_fn.hxx"
      25             : #include "node.hxx"
      26             : #include "format.hxx"
      27             : 
      28         150 : Writer& Out( const SwAttrFnTab pTab, const SfxPoolItem& rHt, Writer & rWrt )
      29             : {
      30         150 :     sal_uInt16 nId = rHt.Which();
      31             :     OSL_ENSURE(  nId < POOLATTR_END && nId >= POOLATTR_BEGIN, "SwAttrFnTab::Out()" );
      32             :     FnAttrOut pOut;
      33         150 :     if( 0 != ( pOut = pTab[ nId - RES_CHRATR_BEGIN] ))
      34         150 :         (*pOut)( rWrt, rHt );
      35         150 :     return rWrt;
      36             : 
      37             : }
      38             : 
      39         652 : Writer& Out_SfxItemSet( const SwAttrFnTab pTab, Writer& rWrt,
      40             :                         const SfxItemSet& rSet, bool bDeep,
      41             :                         bool bTstForDefault )
      42             : {
      43             :     // at first give the own attributes out
      44         652 :     const SfxItemPool& rPool = *rSet.GetPool();
      45         652 :     const SfxItemSet* pSet = &rSet;
      46         652 :     if( !pSet->Count() )        // Optimizing - empty Sets
      47             :     {
      48           0 :         if( !bDeep )
      49           0 :             return rWrt;
      50           0 :         while( 0 != ( pSet = pSet->GetParent() ) && !pSet->Count() )
      51             :             ;
      52           0 :         if( !pSet )
      53           0 :             return rWrt;
      54             :     }
      55         652 :     const SfxPoolItem* pItem(0);
      56             :     FnAttrOut pOut;
      57         652 :     if( !bDeep || !pSet->GetParent() )
      58             :     {
      59             :         OSL_ENSURE( rSet.Count(), "It has been handled already, right?" );
      60         652 :         SfxItemIter aIter( *pSet );
      61         652 :         pItem = aIter.GetCurItem();
      62        5604 :         do {
      63             :             // pTab only covers POOLATTR_BEGIN..POOLATTR_END.
      64        5604 :             if( pItem->Which() <= POOLATTR_END && 0 != ( pOut = pTab[ pItem->Which() - RES_CHRATR_BEGIN] ))
      65        3992 :                     (*pOut)( rWrt, *pItem );
      66        6256 :         } while( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );
      67             :     }
      68             :     else
      69             :     {
      70           0 :         SfxWhichIter aIter( *pSet );
      71           0 :         sal_uInt16 nWhich = aIter.FirstWhich();
      72           0 :         while( nWhich )
      73             :         {
      74           0 :             if( SfxItemState::SET == pSet->GetItemState( nWhich, bDeep, &pItem ) &&
      75           0 :                 ( !bTstForDefault || (
      76           0 :                     *pItem != rPool.GetDefaultItem( nWhich )
      77           0 :                     || ( pSet->GetParent() &&
      78           0 :                         *pItem != pSet->GetParent()->Get( nWhich ))
      79           0 :                 )) && 0 != ( pOut = pTab[ nWhich - RES_CHRATR_BEGIN] ))
      80           0 :                     (*pOut)( rWrt, *pItem );
      81           0 :             nWhich = aIter.NextWhich();
      82           0 :         }
      83             :     }
      84         652 :     return rWrt;
      85             : }
      86             : 
      87       20240 : Writer& Out( const SwNodeFnTab pTab, SwNode& rNode, Writer & rWrt )
      88             : {
      89             :     // It must be a CntntNode!
      90       20240 :     SwCntntNode * pCNd = rNode.GetCntntNode();
      91       20240 :     if( !pCNd )
      92           0 :         return rWrt;
      93             : 
      94       20240 :     sal_uInt16 nId = RES_TXTNODE;
      95       20240 :     switch (pCNd->GetNodeType())
      96             :     {
      97             :         case ND_TEXTNODE:
      98       20240 :             nId = RES_TXTNODE;
      99       20240 :              break;
     100             :         case ND_GRFNODE:
     101           0 :             nId = RES_GRFNODE;
     102           0 :             break;
     103             :         case ND_OLENODE:
     104           0 :             nId = RES_OLENODE;
     105           0 :             break;
     106             :         default:
     107             :             OSL_FAIL("What kind of node is it now?");
     108           0 :             break;
     109             :     }
     110             :     FnNodeOut pOut;
     111       20240 :     if( 0 != ( pOut = pTab[ nId - RES_NODE_BEGIN ] ))
     112       20240 :         (*pOut)( rWrt, *pCNd );
     113       20240 :     return rWrt;
     114         270 : }
     115             : 
     116             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10