LCOV - code coverage report
Current view: top level - comphelper/source/misc - sequence.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 27 55.6 %
Date: 2012-08-25 Functions: 1 2 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 32 34.4 %

           Branch data     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 <comphelper/sequence.hxx>
      21                 :            : 
      22                 :            : //.........................................................................
      23                 :            : namespace comphelper
      24                 :            : {
      25                 :            : //.........................................................................
      26                 :            : 
      27                 :            : //------------------------------------------------------------------------------
      28                 :      10364 : staruno::Sequence<sal_Int16> findValue(const staruno::Sequence< ::rtl::OUString >& _rList, const ::rtl::OUString& _rValue, sal_Bool _bOnlyFirst)
      29                 :            : {
      30                 :      10364 :     sal_Int32 nLength = _rList.getLength();
      31                 :            : 
      32         [ +  - ]:      10364 :     if( _bOnlyFirst )
      33                 :            :     {
      34                 :            :         //////////////////////////////////////////////////////////////////////
      35                 :            :         // An welcher Position finde ich den Wert?
      36                 :      10364 :         sal_Int32 nPos = -1;
      37                 :      10364 :         const ::rtl::OUString* pTArray = _rList.getConstArray();
      38         [ +  + ]:      29208 :         for (sal_Int32 i = 0; i < nLength; ++i, ++pTArray)
      39                 :            :         {
      40         [ +  + ]:      19792 :             if( pTArray->equals(_rValue) )
      41                 :            :             {
      42                 :        948 :                 nPos = i;
      43                 :        948 :                 break;
      44                 :            :             }
      45                 :            :         }
      46                 :            : 
      47                 :            :         //////////////////////////////////////////////////////////////////////
      48                 :            :         // Sequence fuellen
      49         [ +  + ]:      10364 :         if( nPos>-1 )
      50                 :            :         {
      51         [ +  - ]:        948 :             staruno::Sequence<sal_Int16> aRetSeq( 1 );
      52         [ +  - ]:        948 :             aRetSeq.getArray()[0] = (sal_Int16)nPos;
      53                 :            : 
      54 [ +  - ][ +  - ]:        948 :             return aRetSeq;
      55                 :            :         }
      56                 :            : 
      57                 :       9416 :         return staruno::Sequence<sal_Int16>();
      58                 :            : 
      59                 :            :     }
      60                 :            :     else
      61                 :            :     {
      62         [ #  # ]:          0 :         staruno::Sequence<sal_Int16> aRetSeq( nLength );
      63         [ #  # ]:          0 :         sal_Int16* pReturn = aRetSeq.getArray();
      64                 :            : 
      65                 :            :         //////////////////////////////////////////////////////////////////////
      66                 :            :         // Wie oft kommt der Wert vor?
      67                 :          0 :         const ::rtl::OUString* pTArray = _rList.getConstArray();
      68         [ #  # ]:          0 :         for (sal_Int32 i = 0; i < nLength; ++i, ++pTArray)
      69                 :            :         {
      70         [ #  # ]:          0 :             if( pTArray->equals(_rValue) )
      71                 :            :             {
      72                 :          0 :                 *pReturn = (sal_Int16)i;
      73                 :          0 :                 ++pReturn;
      74                 :            :             }
      75                 :            :         }
      76                 :            : 
      77 [ #  # ][ #  # ]:          0 :         aRetSeq.realloc(pReturn - aRetSeq.getArray());
      78                 :            : 
      79 [ #  # ][ #  # ]:      10364 :         return aRetSeq;
      80                 :            :     }
      81                 :            : }
      82                 :            : // -----------------------------------------------------------------------------
      83                 :          0 : sal_Bool existsValue(const ::rtl::OUString& Value,const staruno::Sequence< ::rtl::OUString >& _aList)
      84                 :            : {
      85                 :          0 :     const ::rtl::OUString * pIter   = _aList.getConstArray();
      86                 :          0 :     const ::rtl::OUString * pEnd    = pIter + _aList.getLength();
      87                 :          0 :     return ::std::find(pIter,pEnd,Value) != pEnd;
      88                 :            : }
      89                 :            : 
      90                 :            : //.........................................................................
      91                 :            : }   // namespace comphelper
      92                 :            : //.........................................................................
      93                 :            : 
      94                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10