LCOV - code coverage report
Current view: top level - sw/source/core/doc - DocumentListItemsManager.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 19 41 46.3 %
Date: 2014-11-03 Functions: 8 11 72.7 %
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 <DocumentListItemsManager.hxx>
      21             : #include <SwNodeNum.hxx>
      22             : #include <ndtxt.hxx>
      23             : 
      24             : 
      25             : namespace sw
      26             : {
      27             : 
      28        5052 : DocumentListItemsManager::DocumentListItemsManager() : mpListItemsList( new tImplSortedNodeNumList() ) // #i83479#
      29             : {
      30        5052 : }
      31             : 
      32      187770 : bool DocumentListItemsManager::lessThanNodeNum::operator()( const SwNodeNum* pNodeNumOne,
      33             :                                          const SwNodeNum* pNodeNumTwo ) const
      34             : {
      35      187770 :     return pNodeNumOne->LessThan( *pNodeNumTwo );
      36             : }
      37             : 
      38        7670 : void DocumentListItemsManager::addListItem( const SwNodeNum& rNodeNum )
      39             : {
      40        7670 :     if ( mpListItemsList == 0 )
      41             :     {
      42        7670 :         return;
      43             :     }
      44             : 
      45             :     const bool bAlreadyInserted(
      46        7670 :             mpListItemsList->find( &rNodeNum ) != mpListItemsList->end() );
      47             :     OSL_ENSURE( !bAlreadyInserted,
      48             :             "<DocumentListItemsManager::addListItem(..)> - <SwNodeNum> instance already registered as numbered item!" );
      49        7670 :     if ( !bAlreadyInserted )
      50             :     {
      51        7670 :         mpListItemsList->insert( &rNodeNum );
      52             :     }
      53             : }
      54             : 
      55        7670 : void DocumentListItemsManager::removeListItem( const SwNodeNum& rNodeNum )
      56             : {
      57        7670 :     if ( mpListItemsList == 0 )
      58             :     {
      59        7670 :         return;
      60             :     }
      61             : 
      62        7670 :     const tImplSortedNodeNumList::size_type nDeleted = mpListItemsList->erase( &rNodeNum );
      63             :     if ( nDeleted > 1 )
      64             :     {
      65             :         OSL_FAIL( "<DocumentListItemsManager::removeListItem(..)> - <SwNodeNum> was registered more than once as numbered item!" );
      66             :     }
      67             : }
      68             : 
      69           0 : OUString DocumentListItemsManager::getListItemText( const SwNodeNum& rNodeNum,
      70             :                                const bool bWithNumber,
      71             :                                const bool bWithSpacesForLevel ) const
      72             : {
      73           0 :     return rNodeNum.GetTxtNode()
      74             :            ? rNodeNum.GetTxtNode()->GetExpandTxt( 0, -1, bWithNumber,
      75             :                                                   bWithNumber, bWithSpacesForLevel )
      76           0 :            : OUString();
      77             : }
      78             : 
      79           0 : void DocumentListItemsManager::getListItems( tSortedNodeNumList& orNodeNumList ) const
      80             : {
      81           0 :     orNodeNumList.clear();
      82           0 :     orNodeNumList.reserve( mpListItemsList->size() );
      83             : 
      84           0 :     tImplSortedNodeNumList::iterator aIter;
      85           0 :     tImplSortedNodeNumList::iterator aEndIter = mpListItemsList->end();
      86           0 :     for ( aIter = mpListItemsList->begin(); aIter != aEndIter; ++aIter )
      87             :     {
      88           0 :         orNodeNumList.push_back( (*aIter) );
      89             :     }
      90           0 : }
      91             : 
      92           0 : void DocumentListItemsManager::getNumItems( tSortedNodeNumList& orNodeNumList ) const
      93             : {
      94           0 :     orNodeNumList.clear();
      95           0 :     orNodeNumList.reserve( mpListItemsList->size() );
      96             : 
      97           0 :     tImplSortedNodeNumList::iterator aIter;
      98           0 :     tImplSortedNodeNumList::iterator aEndIter = mpListItemsList->end();
      99           0 :     for ( aIter = mpListItemsList->begin(); aIter != aEndIter; ++aIter )
     100             :     {
     101           0 :         const SwNodeNum* pNodeNum = (*aIter);
     102           0 :         if ( pNodeNum->IsCounted() &&
     103           0 :              pNodeNum->GetTxtNode() && pNodeNum->GetTxtNode()->HasNumber() )
     104             :         {
     105           0 :             orNodeNumList.push_back( pNodeNum );
     106             :         }
     107             :     }
     108           0 : }
     109             : 
     110       15135 : DocumentListItemsManager::~DocumentListItemsManager()
     111             : {
     112             : // #i83479#
     113        5045 : delete mpListItemsList;
     114        5045 : mpListItemsList = 0;
     115       10090 : }
     116             : 
     117             : 
     118         270 : }
     119             : 
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10