LCOV - code coverage report
Current view: top level - sc/source/ui/app - rfindlst.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 39 2.6 %
Date: 2015-06-13 12:38:46 Functions: 2 6 33.3 %
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 "rfindlst.hxx"
      21             : #include <tools/debug.hxx>
      22             : 
      23             : // STATIC DATA -----------------------------------------------------------
      24             : 
      25             : #define SC_RANGECOLORS  8
      26             : 
      27             : static const ColorData aColNames[SC_RANGECOLORS] =
      28             :     { COL_LIGHTBLUE, COL_LIGHTRED, COL_LIGHTMAGENTA, COL_GREEN,
      29             :         COL_BLUE, COL_RED, COL_MAGENTA, COL_BROWN };
      30             : 
      31           0 : ScRangeFindList::ScRangeFindList(const OUString& rName) :
      32             :     aDocName( rName ),
      33             :     bHidden( false ),
      34           0 :     nIndexColor( 0 )
      35             : {
      36           0 : }
      37             : 
      38           0 : ColorData ScRangeFindList::Insert( const ScRangeFindData &rNew )
      39             : {
      40           0 :     std::vector<ScRangeFindData>::iterator it=maEntries.begin();
      41           0 :     for( ; it!=maEntries.end(); ++it)
      42             :     {
      43           0 :         if(it->aRef == rNew.aRef)
      44           0 :             break;
      45             :     }
      46           0 :     ScRangeFindData insertData(rNew);
      47           0 :     insertData.nColorData = ( it != maEntries.end() ? it->nColorData :
      48           0 :                               ScRangeFindList::GetColorName( maEntries.size() ) );
      49           0 :     maEntries.push_back(insertData);
      50           0 :     nIndexColor = maEntries.size() - 1;
      51           0 :     return insertData.nColorData;
      52             : }
      53             : 
      54           0 : ColorData ScRangeFindList::GetColorName( const size_t nIndex )
      55             : {
      56           0 :     return aColNames[nIndex % SC_RANGECOLORS];
      57             : }
      58             : 
      59           0 : ColorData ScRangeFindList::FindColor( const ScRange& rRef, const size_t nIndex )
      60             : {
      61           0 :     sal_Int32 nOldCntr = 0;
      62           0 :     sal_Int32 nNewCntr = 0;
      63           0 :     ColorData nOldColor = 0;
      64           0 :     ColorData nNewColor = 0;
      65             : 
      66             :     DBG_ASSERT( (nIndex < maEntries.size()), "nIndex out of range!" );
      67             : 
      68           0 :     nOldColor = maEntries[nIndex].nColorData;
      69           0 :     nNewColor = ScRangeFindList::GetColorName( nIndex );
      70             : 
      71           0 :     std::vector<ScRangeFindData>::iterator it=maEntries.begin();
      72           0 :     for( ;it!=maEntries.end(); ++it)
      73             :     {
      74           0 :         if(it->aRef == rRef)
      75           0 :             break;
      76             : 
      77           0 :         if (it->nColorData == nOldColor )
      78           0 :             nOldCntr++;
      79             : 
      80           0 :         if (it->nColorData == nNewColor )
      81           0 :             nNewCntr++;
      82             :     }
      83             : 
      84           0 :     if ( it != maEntries.end() )
      85           0 :         return it->nColorData;
      86             : 
      87           0 :     if ( nOldCntr == 1 )
      88           0 :         return nOldColor;
      89             : 
      90           0 :     if ( nNewCntr > 0 )
      91           0 :         return ScRangeFindList::GetColorName( ++nIndexColor );
      92             : 
      93           0 :     return nNewColor;
      94         156 : }
      95             : 
      96             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11