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

Generated by: LCOV version 1.10