LCOV - code coverage report
Current view: top level - sc/source/ui/dbgui - csvsplits.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 41 0.0 %
Date: 2014-04-14 Functions: 0 10 0.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 "csvsplits.hxx"
      21             : 
      22             : #include <algorithm>
      23             : 
      24             : 
      25           0 : bool ScCsvSplits::Insert( sal_Int32 nPos )
      26             : {
      27           0 :     bool bValid = (nPos >= 0);
      28           0 :     if( bValid )
      29             :     {
      30           0 :         iterator aIter = ::std::lower_bound( maVec.begin(), maVec.end(), nPos );
      31           0 :         bValid = (aIter == maVec.end()) || (*aIter != nPos);
      32           0 :         if( bValid )
      33           0 :             aIter = maVec.insert( aIter, nPos );
      34             :     }
      35           0 :     return bValid;
      36             : }
      37             : 
      38           0 : bool ScCsvSplits::Remove( sal_Int32 nPos )
      39             : {
      40           0 :     sal_uInt32 nIndex = GetIndex( nPos );
      41           0 :     bool bValid = (nIndex != CSV_VEC_NOTFOUND);
      42           0 :     if( bValid )
      43           0 :         maVec.erase( maVec.begin() + nIndex );
      44           0 :     return bValid;
      45             : }
      46             : 
      47           0 : void ScCsvSplits::RemoveRange( sal_Int32 nPosStart, sal_Int32 nPosEnd )
      48             : {
      49           0 :     sal_uInt32 nStartIx = LowerBound( nPosStart );
      50           0 :     sal_uInt32 nEndIx = UpperBound( nPosEnd );
      51           0 :     if( (nStartIx != CSV_VEC_NOTFOUND) && (nEndIx != CSV_VEC_NOTFOUND) && (nStartIx <= nEndIx) )
      52           0 :         maVec.erase( maVec.begin() + nStartIx, maVec.begin() + nEndIx + 1 );
      53           0 : }
      54             : 
      55           0 : void ScCsvSplits::Clear()
      56             : {
      57           0 :     maVec.clear();
      58           0 : }
      59             : 
      60           0 : bool ScCsvSplits::HasSplit( sal_Int32 nPos ) const
      61             : {
      62           0 :     return GetIndex( nPos ) != CSV_VEC_NOTFOUND;
      63             : }
      64             : 
      65             : 
      66           0 : sal_uInt32 ScCsvSplits::GetIndex( sal_Int32 nPos ) const
      67             : {
      68           0 :     const_iterator aIter = ::std::lower_bound( maVec.begin(), maVec.end(), nPos );
      69           0 :     return GetIterIndex( ((aIter != maVec.end()) && (*aIter == nPos)) ? aIter : maVec.end() );
      70             : }
      71             : 
      72           0 : sal_uInt32 ScCsvSplits::LowerBound( sal_Int32 nPos ) const
      73             : {
      74           0 :     return GetIterIndex( ::std::lower_bound( maVec.begin(), maVec.end(), nPos ) );
      75             : }
      76             : 
      77           0 : sal_uInt32 ScCsvSplits::UpperBound( sal_Int32 nPos ) const
      78             : {
      79           0 :     sal_uInt32 nIndex = LowerBound( nPos );
      80           0 :     if( nIndex == CSV_VEC_NOTFOUND )
      81           0 :         return Count() ? (Count() - 1) : CSV_VEC_NOTFOUND;
      82           0 :     if( GetPos( nIndex ) == nPos )
      83           0 :         return nIndex;
      84           0 :     return nIndex ? (nIndex - 1) : CSV_VEC_NOTFOUND;
      85             : }
      86             : 
      87           0 : sal_Int32 ScCsvSplits::GetPos( sal_uInt32 nIndex ) const
      88             : {
      89           0 :     return (nIndex < Count()) ? maVec[ nIndex ] : CSV_POS_INVALID;
      90             : }
      91             : 
      92             : 
      93           0 : sal_uInt32 ScCsvSplits::GetIterIndex( const_iterator aIter ) const
      94             : {
      95           0 :     return (aIter == maVec.end()) ? CSV_VEC_NOTFOUND : (aIter - maVec.begin());
      96             : }
      97             : 
      98             : 
      99             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10