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

Generated by: LCOV version 1.10