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

Generated by: LCOV version 1.11