LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/condformat - condformathelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 79 0.0 %
Date: 2012-12-27 Functions: 0 4 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             : 
      10             : #include <rtl/ustrbuf.hxx>
      11             : #include "condformathelper.hxx"
      12             : #include "globstr.hrc"
      13             : 
      14             : namespace {
      15             : 
      16           0 : rtl::OUString getTextForType(ScCondFormatEntryType eType)
      17             : {
      18           0 :     switch(eType)
      19             :     {
      20             :         case CONDITION:
      21           0 :             return ScGlobal::GetRscString(STR_COND_CONDITION);
      22             :         case COLORSCALE:
      23           0 :             return ScGlobal::GetRscString(STR_COND_COLORSCALE);
      24             :         case DATABAR:
      25           0 :             return ScGlobal::GetRscString(STR_COND_DATABAR);
      26             :         case FORMULA:
      27           0 :             return ScGlobal::GetRscString(STR_COND_FORMULA);
      28             :         case ICONSET:
      29           0 :             return ScGlobal::GetRscString(STR_COND_ICONSET);
      30             :         case DATE:
      31           0 :             return ScGlobal::GetRscString(STR_COND_DATE);
      32             :         default:
      33           0 :             break;
      34             :     }
      35             : 
      36           0 :     return rtl::OUString("");
      37             : }
      38             : 
      39           0 : rtl::OUString getExpression(sal_Int32 nIndex)
      40             : {
      41           0 :     switch(nIndex)
      42             :     {
      43             :         case 0:
      44           0 :             return rtl::OUString("=");
      45             :         case 1:
      46           0 :             return rtl::OUString("<");
      47             :         case 2:
      48           0 :             return rtl::OUString(">");
      49             :         case 3:
      50           0 :             return rtl::OUString("<=");
      51             :         case 4:
      52           0 :             return rtl::OUString(">=");
      53             :         case 5:
      54           0 :             return rtl::OUString("!=");
      55             :         case 6:
      56           0 :             return ScGlobal::GetRscString(STR_COND_BETWEEN);
      57             :         case 7:
      58           0 :             return ScGlobal::GetRscString(STR_COND_NOTBETWEEN);
      59             :         case 8:
      60           0 :             return ScGlobal::GetRscString(STR_COND_DUPLICATE);
      61             :         case 9:
      62           0 :             return ScGlobal::GetRscString(STR_COND_UNIQUE);
      63             :         case 10:
      64             :             assert(false);
      65             :         case 11:
      66           0 :             return ScGlobal::GetRscString(STR_COND_TOP10);
      67             :         case 12:
      68           0 :             return ScGlobal::GetRscString(STR_COND_BOTTOM10);
      69             :         case 13:
      70           0 :             return ScGlobal::GetRscString(STR_COND_TOP_PERCENT);
      71             :         case 14:
      72           0 :             return ScGlobal::GetRscString(STR_COND_BOTTOM_PERCENT);
      73             :         case 15:
      74           0 :             return ScGlobal::GetRscString(STR_COND_ABOVE_AVERAGE);
      75             :         case 16:
      76           0 :             return ScGlobal::GetRscString(STR_COND_BELOW_AVERAGE);
      77             :         case 17:
      78           0 :             return ScGlobal::GetRscString(STR_COND_ERROR);
      79             :         case 18:
      80           0 :             return ScGlobal::GetRscString(STR_COND_NOERROR);
      81             :         case 19:
      82           0 :             return ScGlobal::GetRscString(STR_COND_BEGINS_WITH);
      83             :         case 20:
      84           0 :             return ScGlobal::GetRscString(STR_COND_ENDS_WITH);
      85             :         case 21:
      86           0 :             return ScGlobal::GetRscString(STR_COND_CONTAINS);
      87             :         case 22:
      88           0 :             return ScGlobal::GetRscString(STR_COND_NOT_CONTAINS);
      89             :     }
      90           0 :     return rtl::OUString();
      91             : }
      92             : 
      93             : }
      94             : 
      95           0 : rtl::OUString ScCondFormatHelper::GetExpression(const ScConditionalFormat& rFormat, const ScAddress& rPos)
      96             : {
      97           0 :     rtl::OUStringBuffer aBuffer;
      98           0 :     if(!rFormat.IsEmpty())
      99             :     {
     100           0 :         switch(rFormat.GetEntry(0)->GetType())
     101             :         {
     102             :             case condformat::CONDITION:
     103             :                 {
     104           0 :                     const ScConditionEntry* pEntry = static_cast<const ScConditionEntry*>(rFormat.GetEntry(0));
     105           0 :                     ScConditionMode eMode = pEntry->GetOperation();
     106           0 :                     if(eMode == SC_COND_DIRECT)
     107             :                     {
     108           0 :                         aBuffer.append(getTextForType(FORMULA));
     109           0 :                         aBuffer.append(" ");
     110           0 :                         aBuffer.append(pEntry->GetExpression(rPos, 0));
     111             :                     }
     112             :                     else
     113             :                     {
     114           0 :                         aBuffer.append(getTextForType(CONDITION));
     115           0 :                         aBuffer.append(rtl::OUString(" "));
     116           0 :                         aBuffer.append(getExpression(static_cast<sal_Int32>(eMode)));
     117           0 :                         aBuffer.append(rtl::OUString(" "));
     118           0 :                         if(eMode == SC_COND_BETWEEN || eMode == SC_COND_NOTBETWEEN)
     119             :                         {
     120           0 :                             aBuffer.append(pEntry->GetExpression(rPos, 0));
     121           0 :                             aBuffer.append(rtl::OUString(" and "));
     122           0 :                             aBuffer.append(pEntry->GetExpression(rPos, 1));
     123             :                         }
     124           0 :                         else if(eMode <= SC_COND_NOTEQUAL || eMode >= SC_COND_BEGINS_WITH)
     125             :                         {
     126           0 :                             aBuffer.append(pEntry->GetExpression(rPos, 0));
     127             :                         }
     128             :                     }
     129             :                 }
     130             : 
     131           0 :                 break;
     132             :             case condformat::DATABAR:
     133           0 :                 aBuffer.append(getTextForType(DATABAR));
     134           0 :                 break;
     135             :             case condformat::COLORSCALE:
     136           0 :                 aBuffer.append(getTextForType(COLORSCALE));
     137           0 :                 break;
     138             :             case condformat::ICONSET:
     139           0 :                 aBuffer.append(getTextForType(ICONSET));
     140           0 :                 break;
     141             :             case condformat::DATE:
     142           0 :                 aBuffer.append(getTextForType(DATE));
     143           0 :                 break;
     144             :         }
     145             :     }
     146           0 :     return aBuffer.makeStringAndClear();
     147             : }
     148             : 
     149           0 : rtl::OUString ScCondFormatHelper::GetExpression( ScCondFormatEntryType eType, sal_Int32 nIndex,
     150             :         rtl::OUString aStr1, rtl::OUString aStr2 )
     151             : {
     152           0 :     rtl::OUStringBuffer aBuffer(getTextForType(eType));
     153           0 :     aBuffer.append(rtl::OUString(" "));
     154           0 :     if(eType == CONDITION)
     155             :     {
     156             :         // workaround missing FORMULA option in the conditions case
     157             :         // FORMULA is handled later
     158           0 :         if(nIndex > 9)
     159           0 :             ++nIndex;
     160           0 :         aBuffer.append(getExpression(nIndex));
     161           0 :         if(nIndex <= 7 || nIndex >= 19)
     162             :         {
     163           0 :             aBuffer.append(" ").append(aStr1);
     164           0 :             if(nIndex == 6 || nIndex == 7)
     165             :             {
     166           0 :                 aBuffer.append(" and ").append(aStr2);
     167             :             }
     168             :         }
     169             :     }
     170           0 :     else if(eType == FORMULA)
     171             :     {
     172           0 :         aBuffer.append(" ").append(aStr1);
     173             :     }
     174             : 
     175           0 :     return aBuffer.makeStringAndClear();
     176             : }
     177             : 
     178             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10