LCOV - code coverage report
Current view: top level - sc/source/core/data - autonamecache.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 30 76.7 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 57 43.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <unotools/transliterationwrapper.hxx>
      30                 :            : 
      31                 :            : #include "autonamecache.hxx"
      32                 :            : #include "dociter.hxx"
      33                 :            : #include "cell.hxx"
      34                 :            : #include "queryparam.hxx"
      35                 :            : 
      36                 :            : // -----------------------------------------------------------------------
      37                 :            : 
      38                 :        117 : ScAutoNameCache::ScAutoNameCache( ScDocument* pD ) :
      39                 :            :     pDoc( pD ),
      40         [ +  - ]:        117 :     nCurrentTab( 0 )    // doesn't matter - aNames is empty
      41                 :            : {
      42                 :        117 : }
      43                 :            : 
      44                 :        117 : ScAutoNameCache::~ScAutoNameCache()
      45                 :            : {
      46                 :        117 : }
      47                 :            : 
      48                 :         12 : const ScAutoNameAddresses& ScAutoNameCache::GetNameOccurrences( const String& rName, SCTAB nTab )
      49                 :            : {
      50         [ +  + ]:         12 :     if ( nTab != nCurrentTab )
      51                 :            :     {
      52                 :            :         // the lists are valid only for one sheet, so they are cleared when another sheet is used
      53         [ +  - ]:          6 :         aNames.clear();
      54                 :          6 :         nCurrentTab = nTab;
      55                 :            :     }
      56                 :            : 
      57         [ +  - ]:         12 :     ScAutoNameHashMap::const_iterator aFound = aNames.find( rName );
      58 [ -  + ][ +  - ]:         12 :     if ( aFound != aNames.end() )
      59         [ #  # ]:          0 :         return aFound->second;          // already initialized
      60                 :            : 
      61         [ +  - ]:         12 :     ScAutoNameAddresses& rAddresses = aNames[rName];
      62                 :            : 
      63         [ +  - ]:         12 :     ScCellIterator aIter( pDoc, ScRange( 0, 0, nCurrentTab, MAXCOL, MAXROW, nCurrentTab ) );
      64 [ +  - ][ +  - ]:        864 :     for ( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() )
                 [ +  + ]
      65                 :            :     {
      66                 :            :         // don't check code length here, always use the stored result
      67                 :            :         // (AutoCalc is disabled during CompileXML)
      68                 :            : 
      69 [ +  - ][ +  + ]:        852 :         if ( pCell->HasStringData() )
      70                 :            :         {
      71         [ +  - ]:         96 :             String aStr;
      72                 :         96 :             CellType eType = pCell->GetCellType();
      73   [ -  +  -  -  :         96 :             switch ( eType )
                      - ]
      74                 :            :             {
      75                 :            :                 case CELLTYPE_STRING:
      76         [ #  # ]:          0 :                     aStr = ((ScStringCell*)pCell)->GetString();
      77                 :          0 :                 break;
      78                 :            :                 case CELLTYPE_FORMULA:
      79 [ +  - ][ +  - ]:         96 :                     aStr = ((ScFormulaCell*)pCell)->GetString();
                 [ +  - ]
      80                 :         96 :                 break;
      81                 :            :                 case CELLTYPE_EDIT:
      82 [ #  # ][ #  # ]:          0 :                     aStr = ((ScEditCell*)pCell)->GetString();
      83                 :          0 :                 break;
      84                 :            :                 case CELLTYPE_NONE:
      85                 :            :                 case CELLTYPE_VALUE:
      86                 :            :                 case CELLTYPE_NOTE:
      87                 :            :                 case CELLTYPE_SYMBOLS:
      88                 :            : #if OSL_DEBUG_LEVEL > 0
      89                 :            :                 case CELLTYPE_DESTROYED:
      90                 :            : #endif
      91                 :            :                     ;   // nothing, prevent compiler warning
      92                 :          0 :                 break;
      93                 :            :             }
      94 [ +  - ][ +  - ]:         96 :             if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rName ) )
                 [ -  + ]
      95                 :            :             {
      96         [ #  # ]:          0 :                 rAddresses.push_back( ScAddress( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ) );
      97         [ +  - ]:         96 :             }
      98                 :            :         }
      99                 :            :     }
     100                 :            : 
     101                 :         12 :     return rAddresses;
     102                 :            : }
     103                 :            : 
     104                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10