LCOV - code coverage report
Current view: top level - sc/source/core/tool - typedstrdata.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 23 49 46.9 %
Date: 2014-11-03 Functions: 8 13 61.5 %
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             : 
      10             : #include "typedstrdata.hxx"
      11             : #include "global.hxx"
      12             : 
      13             : #include <unotools/collatorwrapper.hxx>
      14             : 
      15          56 : bool ScTypedStrData::LessCaseSensitive::operator() (const ScTypedStrData& left, const ScTypedStrData& right) const
      16             : {
      17          56 :     if (left.meStrType != right.meStrType)
      18           0 :         return left.meStrType < right.meStrType;
      19             : 
      20          56 :     if (left.meStrType == Value)
      21          40 :         return left.mfValue < right.mfValue;
      22             : 
      23          16 :     if (left.mbIsDate != right.mbIsDate)
      24           0 :         return left.mbIsDate < right.mbIsDate;
      25             : 
      26             :     return ScGlobal::GetCaseCollator()->compareString(
      27          16 :         left.maStrValue, right.maStrValue) < 0;
      28             : }
      29             : 
      30          40 : bool ScTypedStrData::LessCaseInsensitive::operator() (const ScTypedStrData& left, const ScTypedStrData& right) const
      31             : {
      32          40 :     if (left.meStrType != right.meStrType)
      33           0 :         return left.meStrType < right.meStrType;
      34             : 
      35          40 :     if (left.meStrType == Value)
      36           0 :         return left.mfValue < right.mfValue;
      37             : 
      38          40 :     if (left.mbIsDate != right.mbIsDate)
      39           0 :         return left.mbIsDate < right.mbIsDate;
      40             : 
      41             :     return ScGlobal::GetCollator()->compareString(
      42          40 :         left.maStrValue, right.maStrValue) < 0;
      43             : }
      44             : 
      45           8 : bool ScTypedStrData::EqualCaseSensitive::operator() (const ScTypedStrData& left, const ScTypedStrData& right) const
      46             : {
      47           8 :     if (left.meStrType != right.meStrType)
      48           0 :         return false;
      49             : 
      50           8 :     if (left.meStrType == Value && left.mfValue != right.mfValue)
      51           0 :         return false;
      52             : 
      53           8 :     if (left.mbIsDate != right.mbIsDate )
      54           0 :         return false;
      55             : 
      56             :     return ScGlobal::GetCaseCollator()->compareString(
      57           8 :         left.maStrValue, right.maStrValue) == 0;
      58             : }
      59             : 
      60           0 : bool ScTypedStrData::EqualCaseInsensitive::operator() (const ScTypedStrData& left, const ScTypedStrData& right) const
      61             : {
      62           0 :     if (left.meStrType != right.meStrType)
      63           0 :         return false;
      64             : 
      65           0 :     if (left.meStrType == Value && left.mfValue != right.mfValue)
      66           0 :         return false;
      67             : 
      68           0 :     if (left.mbIsDate != right.mbIsDate )
      69           0 :         return false;
      70             : 
      71             :     return ScGlobal::GetCollator()->compareString(
      72           0 :         left.maStrValue, right.maStrValue) == 0;
      73             : }
      74             : 
      75           0 : bool ScTypedStrData::operator== (const ScTypedStrData& r) const
      76             : {
      77             :     // Case insensitive comparison by default.
      78             :     EqualCaseInsensitive aHdl;
      79           0 :     return aHdl(*this, r);
      80             : }
      81             : 
      82          40 : bool ScTypedStrData::operator< (const ScTypedStrData& r) const
      83             : {
      84             :     // Case insensitive comparison by default.
      85             :     LessCaseInsensitive aHdl;
      86          40 :     return aHdl(*this, r);
      87             : }
      88             : 
      89          46 : ScTypedStrData::ScTypedStrData(
      90             :     const OUString& rStr, double nVal, StringType nType, bool bDate ) :
      91             :     maStrValue(rStr),
      92             :     mfValue(nVal),
      93             :     meStrType(nType),
      94          46 :     mbIsDate( bDate ) {}
      95             : 
      96          88 : ScTypedStrData::ScTypedStrData( const ScTypedStrData& rCpy ) :
      97             :     maStrValue(rCpy.maStrValue),
      98             :     mfValue(rCpy.mfValue),
      99             :     meStrType(rCpy.meStrType),
     100          88 :     mbIsDate( rCpy.mbIsDate ) {}
     101             : 
     102           0 : bool ScTypedStrData::IsStrData() const
     103             : {
     104           0 :     return meStrType != Value;
     105             : }
     106             : 
     107           0 : FindTypedStrData::FindTypedStrData(const ScTypedStrData& rVal, bool bCaseSens) :
     108           0 :     maVal(rVal), mbCaseSens(bCaseSens) {}
     109             : 
     110           0 : bool FindTypedStrData::operator() (const ScTypedStrData& r) const
     111             : {
     112           0 :     if (mbCaseSens)
     113             :     {
     114             :         ScTypedStrData::EqualCaseSensitive aHdl;
     115           0 :         return aHdl(maVal, r);
     116             :     }
     117             :     else
     118             :     {
     119             :         ScTypedStrData::EqualCaseInsensitive aHdl;
     120           0 :         return aHdl(maVal, r);
     121             :     }
     122         228 : }
     123             : 
     124             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10