LCOV - code coverage report
Current view: top level - sw/source/filter/writer - wrt_fn.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 29 52 55.8 %
Date: 2015-06-13 12:38:46 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          88 : Writer& Out( const SwAttrFnTab pTab, const SfxPoolItem& rHt, Writer & rWrt )
      29             : {
      30          88 :     sal_uInt16 nId = rHt.Which();
      31             :     OSL_ENSURE(  nId < POOLATTR_END && nId >= POOLATTR_BEGIN, "SwAttrFnTab::Out()" );
      32             :     FnAttrOut pOut;
      33          88 :     if( 0 != ( pOut = pTab[ nId - RES_CHRATR_BEGIN] ))
      34          88 :         (*pOut)( rWrt, rHt );
      35          88 :     return rWrt;
      36             : 
      37             : }
      38             : 
      39         338 : 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         338 :     const SfxItemPool& rPool = *rSet.GetPool();
      45         338 :     const SfxItemSet* pSet = &rSet;
      46         338 :     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         338 :     const SfxPoolItem* pItem(0);
      56             :     FnAttrOut pOut;
      57         338 :     if( !bDeep || !pSet->GetParent() )
      58             :     {
      59             :         OSL_ENSURE( rSet.Count(), "It has been handled already, right?" );
      60         338 :         SfxItemIter aIter( *pSet );
      61         338 :         pItem = aIter.GetCurItem();
      62        2875 :         do {
      63             :             // pTab only covers POOLATTR_BEGIN..POOLATTR_END.
      64        2875 :             if( pItem->Which() <= POOLATTR_END && 0 != ( pOut = pTab[ pItem->Which() - RES_CHRATR_BEGIN] ))
      65        2056 :                     (*pOut)( rWrt, *pItem );
      66        3213 :         } 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         338 :     return rWrt;
      85             : }
      86             : 
      87       10761 : Writer& Out( const SwNodeFnTab pTab, SwNode& rNode, Writer & rWrt )
      88             : {
      89             :     // It must be a ContentNode!
      90       10761 :     SwContentNode * pCNd = rNode.GetContentNode();
      91       10761 :     if( !pCNd )
      92           0 :         return rWrt;
      93             : 
      94       10761 :     sal_uInt16 nId = RES_TXTNODE;
      95       10761 :     switch (pCNd->GetNodeType())
      96             :     {
      97             :         case ND_TEXTNODE:
      98       10761 :             nId = RES_TXTNODE;
      99       10761 :              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       10761 :     if( 0 != ( pOut = pTab[ nId - RES_NODE_BEGIN ] ))
     112       10761 :         (*pOut)( rWrt, *pCNd );
     113       10761 :     return rWrt;
     114         177 : }
     115             : 
     116             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11