LCOV - code coverage report
Current view: top level - sc/source/filter/xml - xmlfilti.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 271 418 64.8 %
Date: 2012-08-25 Functions: 47 55 85.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 146 406 36.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "xmlfilti.hxx"
      30                 :            : #include "xmlimprt.hxx"
      31                 :            : #include "docuno.hxx"
      32                 :            : #include "convuno.hxx"
      33                 :            : #include "XMLConverter.hxx"
      34                 :            : #include "rangeutl.hxx"
      35                 :            : #include "queryentry.hxx"
      36                 :            : 
      37                 :            : #include <xmloff/xmltkmap.hxx>
      38                 :            : #include <xmloff/nmspmap.hxx>
      39                 :            : #include <xmloff/xmltoken.hxx>
      40                 :            : 
      41                 :            : using namespace com::sun::star;
      42                 :            : using namespace xmloff::token;
      43                 :            : 
      44                 :            : using ::com::sun::star::uno::Reference;
      45                 :            : using ::com::sun::star::xml::sax::XAttributeList;
      46                 :            : 
      47                 :          9 : ScXMLFilterContext::ConnStackItem::ConnStackItem(bool bOr) : mbOr(bOr), mnCondCount(0) {}
      48                 :            : 
      49                 :          9 : ScXMLFilterContext::ScXMLFilterContext( ScXMLImport& rImport,
      50                 :            :                                         sal_uInt16 nPrfx,
      51                 :            :                                         const rtl::OUString& rLName,
      52                 :            :                                         const Reference<XAttributeList>& xAttrList,
      53                 :            :                                         ScQueryParam& rParam,
      54                 :            :                                         ScXMLDatabaseRangeContext* pTempDatabaseRangeContext) :
      55                 :            :     SvXMLImportContext( rImport, nPrfx, rLName ),
      56                 :            :     mrQueryParam(rParam),
      57                 :            :     pDatabaseRangeContext(pTempDatabaseRangeContext),
      58                 :            :     bSkipDuplicates(false),
      59                 :            :     bCopyOutputData(false),
      60         [ +  - ]:          9 :     bConditionSourceRange(false)
      61                 :            : {
      62                 :          9 :     ScDocument* pDoc(GetScImport().GetDocument());
      63                 :            : 
      64 [ +  - ][ +  - ]:          9 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
                 [ +  - ]
      65         [ +  - ]:          9 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetFilterAttrTokenMap();
      66         [ -  + ]:          9 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
      67                 :            :     {
      68 [ #  # ][ #  # ]:          0 :         const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
      69                 :          0 :         rtl::OUString aLocalName;
      70                 :          0 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
      71         [ #  # ]:          0 :                                             sAttrName, &aLocalName );
      72 [ #  # ][ #  # ]:          0 :         const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
      73                 :            : 
      74 [ #  # ][ #  #  :          0 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
                #  #  # ]
      75                 :            :         {
      76                 :            :             case XML_TOK_FILTER_ATTR_TARGET_RANGE_ADDRESS :
      77                 :            :             {
      78                 :          0 :                 ScRange aScRange;
      79                 :          0 :                 sal_Int32 nOffset(0);
      80 [ #  # ][ #  # ]:          0 :                 if (ScRangeStringConverter::GetRangeFromString( aScRange, sValue, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset ))
      81                 :            :                 {
      82                 :          0 :                     ScUnoConversion::FillApiAddress( aOutputPosition, aScRange.aStart );
      83                 :          0 :                     bCopyOutputData = true;
      84                 :            :                 }
      85                 :            :             }
      86                 :          0 :             break;
      87                 :            :             case XML_TOK_FILTER_ATTR_CONDITION_SOURCE_RANGE_ADDRESS :
      88                 :            :             {
      89                 :          0 :                 sal_Int32 nOffset(0);
      90 [ #  # ][ #  # ]:          0 :                 if (ScRangeStringConverter::GetRangeFromString( aConditionSourceRangeAddress, sValue, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset ))
      91                 :          0 :                     bConditionSourceRange = true;
      92                 :            :             }
      93                 :          0 :             break;
      94                 :            :             case XML_TOK_FILTER_ATTR_CONDITION_SOURCE :
      95                 :            :             {
      96                 :            :                 // not supported by StarOffice
      97                 :            :             }
      98                 :          0 :             break;
      99                 :            :             case XML_TOK_FILTER_ATTR_DISPLAY_DUPLICATES :
     100                 :            :             {
     101         [ #  # ]:          0 :                 bSkipDuplicates = !IsXMLToken(sValue, XML_TRUE);
     102                 :            :             }
     103                 :          0 :             break;
     104                 :            :         }
     105                 :          0 :     }
     106                 :          9 : }
     107                 :            : 
     108                 :          9 : ScXMLFilterContext::~ScXMLFilterContext()
     109                 :            : {
     110         [ -  + ]:         18 : }
     111                 :            : 
     112                 :          9 : SvXMLImportContext *ScXMLFilterContext::CreateChildContext( sal_uInt16 nPrefix,
     113                 :            :                                             const ::rtl::OUString& rLName,
     114                 :            :                                             const ::com::sun::star::uno::Reference<
     115                 :            :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
     116                 :            : {
     117                 :          9 :     SvXMLImportContext *pContext(0);
     118                 :            : 
     119                 :          9 :     const SvXMLTokenMap& rTokenMap(GetScImport().GetFilterElemTokenMap());
     120   [ +  +  -  - ]:          9 :     switch( rTokenMap.Get( nPrefix, rLName ) )
     121                 :            :     {
     122                 :            :         case XML_TOK_FILTER_AND:
     123                 :            :         {
     124                 :            :             pContext = new ScXMLAndContext(
     125         [ +  - ]:          2 :                 GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, this);
     126                 :            :         }
     127                 :          2 :         break;
     128                 :            :         case XML_TOK_FILTER_OR:
     129                 :            :         {
     130                 :            :             pContext = new ScXMLOrContext(
     131         [ +  - ]:          7 :                 GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, this);
     132                 :            :         }
     133                 :          7 :         break;
     134                 :            :         case XML_TOK_FILTER_CONDITION:
     135                 :            :         {
     136                 :            :             pContext = new ScXMLConditionContext(
     137         [ #  # ]:          0 :                 GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, this);
     138                 :            :         }
     139                 :          0 :         break;
     140                 :            :     }
     141                 :            : 
     142         [ -  + ]:          9 :     if( !pContext )
     143         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     144                 :            : 
     145                 :          9 :     return pContext;
     146                 :            : }
     147                 :            : 
     148                 :          9 : void ScXMLFilterContext::EndElement()
     149                 :            : {
     150                 :          9 :     mrQueryParam.bInplace = !bCopyOutputData;
     151                 :          9 :     mrQueryParam.bDuplicate = !bSkipDuplicates;
     152                 :            : 
     153         [ -  + ]:          9 :     if (bCopyOutputData)
     154                 :            :     {
     155                 :          0 :         mrQueryParam.nDestCol = aOutputPosition.Column;
     156                 :          0 :         mrQueryParam.nDestRow = aOutputPosition.Row;
     157                 :          0 :         mrQueryParam.nDestTab = aOutputPosition.Sheet;
     158                 :            :     }
     159                 :            : 
     160         [ -  + ]:          9 :     if (bConditionSourceRange)
     161                 :          0 :         pDatabaseRangeContext->SetFilterConditionSourceRangeAddress(aConditionSourceRangeAddress);
     162                 :          9 : }
     163                 :            : 
     164                 :          9 : void ScXMLFilterContext::OpenConnection(bool b)
     165                 :            : {
     166         [ +  - ]:          9 :     maConnStack.push_back(ConnStackItem(b));
     167                 :          9 : }
     168                 :            : 
     169                 :          9 : void ScXMLFilterContext::CloseConnection()
     170                 :            : {
     171                 :          9 :     maConnStack.pop_back();
     172                 :          9 : }
     173                 :            : 
     174                 :         11 : bool ScXMLFilterContext::GetConnection()
     175                 :            : {
     176                 :            :     // For condition items in each stack, the first one gets the connection of
     177                 :            :     // the last stack, while the rest of them get that of the current stack.
     178                 :            : 
     179         [ -  + ]:         11 :     if (maConnStack.empty())
     180                 :            :         // This should never happen.
     181                 :          0 :         return true;
     182                 :            : 
     183         [ +  - ]:         11 :     ConnStackItem& rItem = maConnStack.back();
     184         [ -  + ]:         11 :     if (rItem.mnCondCount)
     185                 :            :         // secondary item gets the current connection.
     186                 :          0 :         return rItem.mbOr;
     187                 :            : 
     188         [ +  - ]:         11 :     if (maConnStack.size() < 2)
     189                 :            :         // There is no last stack.  Likely the first condition in the first
     190                 :            :         // stack whose connection is not used.
     191                 :         11 :         return true;
     192                 :            : 
     193                 :          0 :     ++rItem.mnCondCount;
     194                 :          0 :     std::vector<ConnStackItem>::reverse_iterator itr = maConnStack.rbegin();
     195         [ #  # ]:          0 :     ++itr;
     196         [ #  # ]:         11 :     return itr->mbOr; // connection of the last stack.
     197                 :            : }
     198                 :            : 
     199                 :          2 : ScXMLAndContext::ScXMLAndContext( ScXMLImport& rImport,
     200                 :            :                                   sal_uInt16 nPrfx,
     201                 :            :                                   const rtl::OUString& rLName,
     202                 :            :                                   const Reference<XAttributeList>& /* xAttrList */,
     203                 :            :                                   ScQueryParam& rParam,
     204                 :            :                                   ScXMLFilterContext* pTempFilterContext) :
     205                 :            :     SvXMLImportContext( rImport, nPrfx, rLName ),
     206                 :            :     mrQueryParam(rParam),
     207                 :          2 :     pFilterContext(pTempFilterContext)
     208                 :            : {
     209         [ +  - ]:          2 :     pFilterContext->OpenConnection(false);
     210                 :          2 : }
     211                 :            : 
     212                 :          2 : ScXMLAndContext::~ScXMLAndContext()
     213                 :            : {
     214         [ -  + ]:          4 : }
     215                 :            : 
     216                 :          2 : SvXMLImportContext *ScXMLAndContext::CreateChildContext( sal_uInt16 nPrefix,
     217                 :            :                                             const ::rtl::OUString& rLName,
     218                 :            :                                             const ::com::sun::star::uno::Reference<
     219                 :            :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
     220                 :            : {
     221                 :          2 :     SvXMLImportContext *pContext(0);
     222                 :            : 
     223                 :          2 :     const SvXMLTokenMap& rTokenMap(GetScImport().GetFilterElemTokenMap());
     224      [ -  +  - ]:          2 :     switch( rTokenMap.Get( nPrefix, rLName ) )
     225                 :            :     {
     226                 :            :         case XML_TOK_FILTER_OR:
     227                 :            :         {
     228                 :            :             // not supported in StarOffice
     229                 :            :         }
     230                 :          0 :         break;
     231                 :            :         case XML_TOK_FILTER_CONDITION:
     232                 :            :         {
     233                 :            :             pContext = new ScXMLConditionContext(
     234         [ +  - ]:          2 :                 GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, pFilterContext);
     235                 :            :         }
     236                 :          2 :         break;
     237                 :            :     }
     238                 :            : 
     239         [ -  + ]:          2 :     if( !pContext )
     240         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     241                 :            : 
     242                 :          2 :     return pContext;
     243                 :            : }
     244                 :            : 
     245                 :          2 : void ScXMLAndContext::EndElement()
     246                 :            : {
     247                 :          2 :     pFilterContext->CloseConnection();
     248                 :          2 : }
     249                 :            : 
     250                 :          7 : ScXMLOrContext::ScXMLOrContext( ScXMLImport& rImport,
     251                 :            :                                 sal_uInt16 nPrfx,
     252                 :            :                                 const rtl::OUString& rLName,
     253                 :            :                                 const Reference<
     254                 :            :                                     ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
     255                 :            :                                 ScQueryParam& rParam,
     256                 :            :                                 ScXMLFilterContext* pTempFilterContext) :
     257                 :            :     SvXMLImportContext( rImport, nPrfx, rLName ),
     258                 :            :     mrQueryParam(rParam),
     259                 :          7 :     pFilterContext(pTempFilterContext)
     260                 :            : {
     261         [ +  - ]:          7 :     pFilterContext->OpenConnection(true);
     262                 :          7 : }
     263                 :            : 
     264                 :          7 : ScXMLOrContext::~ScXMLOrContext()
     265                 :            : {
     266         [ -  + ]:         14 : }
     267                 :            : 
     268                 :          9 : SvXMLImportContext *ScXMLOrContext::CreateChildContext( sal_uInt16 nPrefix,
     269                 :            :                                             const ::rtl::OUString& rLName,
     270                 :            :                                             const ::com::sun::star::uno::Reference<
     271                 :            :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
     272                 :            : {
     273                 :          9 :     SvXMLImportContext *pContext(0);
     274                 :            : 
     275                 :          9 :     const SvXMLTokenMap& rTokenMap(GetScImport().GetFilterElemTokenMap());
     276      [ -  +  - ]:          9 :     switch( rTokenMap.Get( nPrefix, rLName ) )
     277                 :            :     {
     278                 :            :         case XML_TOK_FILTER_AND:
     279                 :            :         {
     280                 :            :             pContext = new ScXMLAndContext(
     281         [ #  # ]:          0 :                 GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, pFilterContext);
     282                 :            :         }
     283                 :          0 :         break;
     284                 :            :         case XML_TOK_FILTER_CONDITION:
     285                 :            :         {
     286                 :            :             pContext = new ScXMLConditionContext(
     287         [ +  - ]:          9 :                 GetScImport(), nPrefix, rLName, xAttrList, mrQueryParam, pFilterContext);
     288                 :            :         }
     289                 :          9 :         break;
     290                 :            :     }
     291                 :            : 
     292         [ -  + ]:          9 :     if( !pContext )
     293         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     294                 :            : 
     295                 :          9 :     return pContext;
     296                 :            : }
     297                 :            : 
     298                 :          7 : void ScXMLOrContext::EndElement()
     299                 :            : {
     300                 :          7 :     pFilterContext->CloseConnection();
     301                 :          7 : }
     302                 :            : 
     303                 :         11 : ScXMLConditionContext::ScXMLConditionContext(
     304                 :            :     ScXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName,
     305                 :            :     const Reference<XAttributeList>& xAttrList,
     306                 :            :     ScQueryParam& rParam,
     307                 :            :     ScXMLFilterContext* pTempFilterContext) :
     308                 :            :     SvXMLImportContext( rImport, nPrfx, rLName ),
     309                 :            :     mrQueryParam(rParam),
     310                 :            :     pFilterContext(pTempFilterContext),
     311         [ +  - ]:         11 :     bIsCaseSensitive(false)
     312                 :            : {
     313         [ +  - ]:         11 :     sDataType = GetXMLToken(XML_TEXT);
     314                 :            : 
     315 [ +  - ][ +  - ]:         11 :     sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
                 [ +  - ]
     316         [ +  - ]:         11 :     const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetFilterConditionAttrTokenMap());
     317         [ +  + ]:         44 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
     318                 :            :     {
     319 [ +  - ][ +  - ]:         33 :         const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
     320                 :         33 :         rtl::OUString aLocalName;
     321                 :         33 :         sal_uInt16 nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
     322         [ +  - ]:         33 :                                             sAttrName, &aLocalName );
     323 [ +  - ][ +  - ]:         33 :         const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
     324                 :            : 
     325 [ +  - ][ +  -  :         33 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
             -  +  +  - ]
     326                 :            :         {
     327                 :            :             case XML_TOK_CONDITION_ATTR_FIELD_NUMBER :
     328                 :            :             {
     329                 :         11 :                 nField = sValue.toInt32();
     330                 :            :             }
     331                 :         11 :             break;
     332                 :            :             case XML_TOK_CONDITION_ATTR_CASE_SENSITIVE :
     333                 :            :             {
     334         [ #  # ]:          0 :                 bIsCaseSensitive = IsXMLToken(sValue, XML_TRUE);
     335                 :            :             }
     336                 :          0 :             break;
     337                 :            :             case XML_TOK_CONDITION_ATTR_DATA_TYPE :
     338                 :            :             {
     339                 :          0 :                 sDataType = sValue;
     340                 :            :             }
     341                 :          0 :             break;
     342                 :            :             case XML_TOK_CONDITION_ATTR_VALUE :
     343                 :            :             {
     344                 :         11 :                 sConditionValue = sValue;
     345                 :            :             }
     346                 :         11 :             break;
     347                 :            :             case XML_TOK_CONDITION_ATTR_OPERATOR :
     348                 :            :             {
     349                 :         11 :                 sOperator = sValue;
     350                 :            :             }
     351                 :         11 :             break;
     352                 :            :         }
     353                 :         33 :     }
     354                 :         11 : }
     355                 :            : 
     356                 :         11 : ScXMLConditionContext::~ScXMLConditionContext()
     357                 :            : {
     358         [ -  + ]:         22 : }
     359                 :            : 
     360                 :         16 : SvXMLImportContext *ScXMLConditionContext::CreateChildContext( sal_uInt16 nPrefix,
     361                 :            :                                             const ::rtl::OUString& rLName,
     362                 :            :                                             const Reference<XAttributeList>& xAttrList )
     363                 :            : {
     364                 :         16 :     SvXMLImportContext *pContext = NULL;
     365                 :            : 
     366                 :         16 :     const SvXMLTokenMap& rTokenMap(GetScImport().GetFilterConditionElemTokenMap());
     367         [ +  - ]:         16 :     switch( rTokenMap.Get( nPrefix, rLName ) )
     368                 :            :     {
     369                 :            :         case XML_TOK_CONDITION_FILTER_SET_ITEM:
     370                 :            :         {
     371                 :            :             pContext = new ScXMLSetItemContext(
     372         [ +  - ]:         16 :                 GetScImport(), nPrefix, rLName, xAttrList, *this);
     373                 :            :         }
     374                 :         16 :         break;
     375                 :            :     }
     376                 :            : 
     377         [ -  + ]:         16 :     if( !pContext )
     378         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     379                 :            : 
     380                 :         16 :     return pContext;
     381                 :            : }
     382                 :            : 
     383                 :         11 : void ScXMLConditionContext::GetOperator(
     384                 :            :     const rtl::OUString& aOpStr, ScQueryParam& rParam, ScQueryEntry& rEntry) const
     385                 :            : {
     386                 :         11 :     rParam.bRegExp = false;
     387         [ -  + ]:         11 :     if (IsXMLToken(aOpStr, XML_MATCH))
     388                 :            :     {
     389                 :          0 :         rParam.bRegExp = true;
     390                 :          0 :         rEntry.eOp = SC_EQUAL;
     391                 :            :     }
     392         [ -  + ]:         11 :     else if (IsXMLToken(aOpStr, XML_NOMATCH))
     393                 :            :     {
     394                 :          0 :         rParam.bRegExp = true;
     395                 :          0 :         rEntry.eOp = SC_NOT_EQUAL;
     396                 :            :     }
     397         [ +  - ]:         11 :     else if (aOpStr.compareToAscii("=") == 0)
     398                 :         11 :         rEntry.eOp = SC_EQUAL;
     399         [ #  # ]:          0 :     else if (aOpStr.compareToAscii("!=") == 0)
     400                 :          0 :         rEntry.eOp = SC_NOT_EQUAL;
     401         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_BOTTOM_PERCENT))
     402                 :          0 :         rEntry.eOp = SC_BOTPERC;
     403         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_BOTTOM_VALUES))
     404                 :          0 :         rEntry.eOp = SC_BOTVAL;
     405         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_EMPTY))
     406                 :          0 :         rEntry.SetQueryByEmpty();
     407         [ #  # ]:          0 :     else if (aOpStr.compareToAscii(">") == 0)
     408                 :          0 :         rEntry.eOp = SC_GREATER;
     409         [ #  # ]:          0 :     else if (aOpStr.compareToAscii(">=") == 0)
     410                 :          0 :         rEntry.eOp = SC_GREATER_EQUAL;
     411         [ #  # ]:          0 :     else if (aOpStr.compareToAscii("<") == 0)
     412                 :          0 :         rEntry.eOp = SC_LESS;
     413         [ #  # ]:          0 :     else if (aOpStr.compareToAscii("<=") == 0)
     414                 :          0 :         rEntry.eOp = SC_LESS_EQUAL;
     415         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_NOEMPTY))
     416                 :          0 :         rEntry.SetQueryByNonEmpty();
     417         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_TOP_PERCENT))
     418                 :          0 :         rEntry.eOp = SC_TOPPERC;
     419         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_TOP_VALUES))
     420                 :          0 :         rEntry.eOp = SC_TOPVAL;
     421         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_CONTAINS))
     422                 :          0 :         rEntry.eOp = SC_CONTAINS;
     423         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_DOES_NOT_CONTAIN))
     424                 :          0 :         rEntry.eOp = SC_DOES_NOT_CONTAIN;
     425         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_BEGINS_WITH))
     426                 :          0 :         rEntry.eOp = SC_BEGINS_WITH;
     427         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_DOES_NOT_BEGIN_WITH))
     428                 :          0 :         rEntry.eOp = SC_DOES_NOT_BEGIN_WITH;
     429         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_ENDS_WITH))
     430                 :          0 :         rEntry.eOp = SC_ENDS_WITH;
     431         [ #  # ]:          0 :     else if (IsXMLToken(aOpStr, XML_DOES_NOT_END_WITH))
     432                 :          0 :         rEntry.eOp = SC_DOES_NOT_END_WITH;
     433                 :         11 : }
     434                 :            : 
     435                 :         16 : void ScXMLConditionContext::AddSetItem(const ScQueryEntry::Item& rItem)
     436                 :            : {
     437                 :         16 :     maQueryItems.push_back(rItem);
     438                 :         16 : }
     439                 :            : 
     440                 :         11 : void ScXMLConditionContext::EndElement()
     441                 :            : {
     442                 :         11 :     ScQueryEntry& rEntry = mrQueryParam.AppendEntry();
     443                 :            : 
     444                 :            :     // We currently don't support per-condition case sensitivity.
     445                 :         11 :     mrQueryParam.bCaseSens = bIsCaseSensitive;
     446                 :            : 
     447                 :         11 :     rEntry.bDoQuery = true;
     448         [ +  - ]:         11 :     rEntry.eConnect = pFilterContext->GetConnection() ? SC_OR : SC_AND;
     449                 :            : 
     450                 :         11 :     GetOperator(sOperator, mrQueryParam, rEntry);
     451         [ +  - ]:         11 :     SCCOLROW nStartPos = mrQueryParam.bByRow ? mrQueryParam.nCol1 : mrQueryParam.nRow1;
     452                 :         11 :     rEntry.nField = nField + nStartPos;
     453                 :            : 
     454         [ +  + ]:         11 :     if (maQueryItems.empty())
     455                 :            :     {
     456                 :          5 :         ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
     457         [ -  + ]:          5 :         if (IsXMLToken(sDataType, XML_NUMBER))
     458                 :            :         {
     459                 :          0 :             rItem.mfVal = sConditionValue.toDouble();
     460                 :          0 :             rItem.meType = ScQueryEntry::ByValue;
     461                 :            :         }
     462                 :            :         else
     463                 :            :         {
     464                 :          5 :             rItem.maString = sConditionValue;
     465                 :          5 :             rItem.meType = ScQueryEntry::ByString;
     466                 :            :         }
     467                 :            :     }
     468                 :            :     else
     469                 :          6 :         rEntry.GetQueryItems().swap(maQueryItems);
     470                 :         11 : }
     471                 :            : 
     472                 :          0 : const ScXMLImport& ScXMLSetItemContext::GetScImport() const
     473                 :            : {
     474                 :          0 :     return static_cast<const ScXMLImport&>(GetImport());
     475                 :            : }
     476                 :            : 
     477                 :         32 : ScXMLImport& ScXMLSetItemContext::GetScImport()
     478                 :            : {
     479                 :         32 :     return static_cast<ScXMLImport&>(GetImport());
     480                 :            : }
     481                 :            : 
     482                 :         16 : ScXMLSetItemContext::ScXMLSetItemContext(
     483                 :            :     ScXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLName,
     484                 :            :     const Reference<XAttributeList>& xAttrList, ScXMLConditionContext& rParent) :
     485                 :         16 :     SvXMLImportContext(rImport, nPrfx, rLName)
     486                 :            : {
     487 [ +  - ][ +  - ]:         16 :     sal_Int32 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
                 [ +  - ]
     488         [ +  - ]:         16 :     const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetFilterSetItemAttrTokenMap();
     489         [ +  + ]:         32 :     for (sal_Int32 i = 0; i < nAttrCount; ++i)
     490                 :            :     {
     491 [ +  - ][ +  - ]:         16 :         const rtl::OUString& sAttrName = xAttrList->getNameByIndex(i);
     492                 :         16 :         rtl::OUString aLocalName;
     493                 :            :         sal_uInt16 nPrefix =
     494         [ +  - ]:         16 :             GetScImport().GetNamespaceMap().GetKeyByAttrName(sAttrName, &aLocalName);
     495                 :            : 
     496 [ +  - ][ +  - ]:         16 :         const rtl::OUString& sValue = xAttrList->getValueByIndex(i);
     497                 :            : 
     498 [ +  - ][ +  - ]:         16 :         switch (rAttrTokenMap.Get(nPrefix, aLocalName))
     499                 :            :         {
     500                 :            :             case XML_TOK_FILTER_SET_ITEM_ATTR_VALUE:
     501                 :            :             {
     502                 :         16 :                 ScQueryEntry::Item aItem;
     503                 :         16 :                 aItem.maString = sValue;
     504                 :         16 :                 aItem.meType = ScQueryEntry::ByString;
     505                 :         16 :                 aItem.mfVal = 0.0;
     506 [ +  - ][ +  - ]:         16 :                 rParent.AddSetItem(aItem);
     507                 :            :             }
     508                 :         16 :             break;
     509                 :            :         }
     510                 :         16 :     }
     511                 :         16 : }
     512                 :            : 
     513                 :          0 : SvXMLImportContext* ScXMLSetItemContext::CreateChildContext(
     514                 :            :     sal_uInt16 nPrefix, const ::rtl::OUString& rLName,
     515                 :            :     const Reference<XAttributeList>& /*xAttrList*/ )
     516                 :            : {
     517         [ #  # ]:          0 :     return new SvXMLImportContext( GetImport(), nPrefix, rLName );;
     518                 :            : }
     519                 :            : 
     520                 :         16 : ScXMLSetItemContext::~ScXMLSetItemContext()
     521                 :            : {
     522         [ -  + ]:         32 : }
     523                 :            : 
     524                 :         16 : void ScXMLSetItemContext::EndElement()
     525                 :            : {
     526                 :         16 : }
     527                 :            : 
     528                 :            : //==========================================================================
     529                 :            : 
     530                 :          2 : ScXMLDPFilterContext::ScXMLDPFilterContext( ScXMLImport& rImport,
     531                 :            :                                       sal_uInt16 nPrfx,
     532                 :            :                                       const ::rtl::OUString& rLName,
     533                 :            :                                       const ::com::sun::star::uno::Reference<
     534                 :            :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
     535                 :            :                                         ScXMLDataPilotTableContext* pTempDataPilotTableContext) :
     536                 :            :     SvXMLImportContext( rImport, nPrfx, rLName ),
     537                 :            :     pDataPilotTable(pTempDataPilotTableContext),
     538                 :            :     aFilterFields(),
     539                 :            :     nFilterFieldCount(0),
     540                 :            :     bSkipDuplicates(false),
     541                 :            :     bCopyOutputData(false),
     542                 :            :     bUseRegularExpressions(false),
     543                 :            :     bConnectionOr(true),
     544                 :            :     bNextConnectionOr(true),
     545 [ +  - ][ +  - ]:          2 :     bConditionSourceRange(false)
                 [ +  - ]
     546                 :            : {
     547                 :          2 :     ScDocument* pDoc(GetScImport().GetDocument());
     548                 :            : 
     549 [ +  - ][ +  - ]:          2 :     sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
                 [ +  - ]
     550         [ +  - ]:          2 :     const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetFilterAttrTokenMap());
     551         [ +  + ]:          4 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
     552                 :            :     {
     553 [ +  - ][ +  - ]:          2 :         const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
     554                 :          2 :         rtl::OUString aLocalName;
     555                 :          2 :         sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
     556         [ +  - ]:          2 :                                             sAttrName, &aLocalName ));
     557 [ +  - ][ +  - ]:          2 :         const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
     558                 :            : 
     559 [ +  - ][ -  +  :          2 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
                -  -  - ]
     560                 :            :         {
     561                 :            :             case XML_TOK_FILTER_ATTR_TARGET_RANGE_ADDRESS :
     562                 :            :             {
     563                 :          0 :                 ScRange aScRange;
     564                 :          0 :                 sal_Int32 nOffset(0);
     565 [ #  # ][ #  # ]:          0 :                 if (ScRangeStringConverter::GetRangeFromString( aScRange, sValue, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset ))
     566                 :            :                 {
     567                 :          0 :                     aOutputPosition = aScRange.aStart;
     568                 :          0 :                     bCopyOutputData = true;
     569                 :            :                 }
     570                 :            :             }
     571                 :          0 :             break;
     572                 :            :             case XML_TOK_FILTER_ATTR_CONDITION_SOURCE_RANGE_ADDRESS :
     573                 :            :             {
     574                 :          2 :                 sal_Int32 nOffset(0);
     575 [ +  - ][ -  + ]:          2 :                 if(ScRangeStringConverter::GetRangeFromString( aConditionSourceRangeAddress, sValue, pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset ))
     576                 :          0 :                     bConditionSourceRange = true;
     577                 :            :             }
     578                 :          2 :             break;
     579                 :            :             case XML_TOK_FILTER_ATTR_CONDITION_SOURCE :
     580                 :            :             {
     581                 :            :                 // not supported by StarOffice
     582                 :            :             }
     583                 :          0 :             break;
     584                 :            :             case XML_TOK_FILTER_ATTR_DISPLAY_DUPLICATES :
     585                 :            :             {
     586         [ #  # ]:          0 :                 bSkipDuplicates = !IsXMLToken(sValue, XML_TRUE);
     587                 :            :             }
     588                 :          0 :             break;
     589                 :            :         }
     590                 :          2 :     }
     591                 :          2 : }
     592                 :            : 
     593         [ +  - ]:          2 : ScXMLDPFilterContext::~ScXMLDPFilterContext()
     594                 :            : {
     595         [ -  + ]:          4 : }
     596                 :            : 
     597                 :          2 : SvXMLImportContext *ScXMLDPFilterContext::CreateChildContext( sal_uInt16 nPrefix,
     598                 :            :                                             const ::rtl::OUString& rLName,
     599                 :            :                                             const ::com::sun::star::uno::Reference<
     600                 :            :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
     601                 :            : {
     602                 :          2 :     SvXMLImportContext *pContext(0);
     603                 :            : 
     604                 :          2 :     const SvXMLTokenMap& rTokenMap(GetScImport().GetFilterElemTokenMap());
     605   [ +  -  -  - ]:          2 :     switch( rTokenMap.Get( nPrefix, rLName ) )
     606                 :            :     {
     607                 :            :         case XML_TOK_FILTER_AND:
     608                 :            :         {
     609                 :            :             pContext = new ScXMLDPAndContext( GetScImport(), nPrefix,
     610         [ +  - ]:          2 :                                                           rLName, xAttrList, this);
     611                 :            :         }
     612                 :          2 :         break;
     613                 :            :         case XML_TOK_FILTER_OR:
     614                 :            :         {
     615                 :            :             pContext = new ScXMLDPOrContext( GetScImport(), nPrefix,
     616         [ #  # ]:          0 :                                                           rLName, xAttrList, this);
     617                 :            :         }
     618                 :          0 :         break;
     619                 :            :         case XML_TOK_FILTER_CONDITION:
     620                 :            :         {
     621                 :            :             pContext = new ScXMLDPConditionContext( GetScImport(), nPrefix,
     622         [ #  # ]:          0 :                                                           rLName, xAttrList, this);
     623                 :            :         }
     624                 :          0 :         break;
     625                 :            :     }
     626                 :            : 
     627         [ -  + ]:          2 :     if( !pContext )
     628         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     629                 :            : 
     630                 :          2 :     return pContext;
     631                 :            : }
     632                 :            : 
     633                 :          2 : void ScXMLDPFilterContext::EndElement()
     634                 :            : {
     635                 :          2 :     aFilterFields.bRegExp = bUseRegularExpressions;
     636                 :          2 :     aFilterFields.bCaseSens = bIsCaseSensitive;
     637                 :          2 :     aFilterFields.bDuplicate = !bSkipDuplicates;
     638         [ -  + ]:          2 :     if (bCopyOutputData)
     639                 :          0 :         pDataPilotTable->SetFilterOutputPosition(aOutputPosition);
     640                 :            : 
     641                 :          2 :     pDataPilotTable->SetSourceQueryParam(aFilterFields);
     642         [ -  + ]:          2 :     if (bConditionSourceRange)
     643                 :          0 :         pDataPilotTable->SetFilterSourceRange(aConditionSourceRangeAddress);
     644                 :          2 : }
     645                 :            : 
     646                 :          4 : void ScXMLDPFilterContext::AddFilterField (const ScQueryEntry& aFilterField)
     647                 :            : {
     648                 :          4 :     aFilterFields.Resize(nFilterFieldCount + 1);
     649                 :          4 :     ScQueryEntry& rEntry(aFilterFields.GetEntry(nFilterFieldCount));
     650                 :          4 :     rEntry = aFilterField;
     651                 :          4 :     rEntry.bDoQuery = true;
     652                 :          4 :     ++nFilterFieldCount;
     653                 :          4 : }
     654                 :            : 
     655                 :          2 : ScXMLDPAndContext::ScXMLDPAndContext( ScXMLImport& rImport,
     656                 :            :                                       sal_uInt16 nPrfx,
     657                 :            :                                       const ::rtl::OUString& rLName,
     658                 :            :                                       const ::com::sun::star::uno::Reference<
     659                 :            :                                       ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
     660                 :            :                                         ScXMLDPFilterContext* pTempFilterContext) :
     661                 :          2 :     SvXMLImportContext( rImport, nPrfx, rLName )
     662                 :            : {
     663                 :          2 :     pFilterContext = pTempFilterContext;
     664         [ +  - ]:          2 :     pFilterContext->OpenConnection(false);
     665                 :          2 : }
     666                 :            : 
     667                 :          2 : ScXMLDPAndContext::~ScXMLDPAndContext()
     668                 :            : {
     669         [ -  + ]:          4 : }
     670                 :            : 
     671                 :          4 : SvXMLImportContext *ScXMLDPAndContext::CreateChildContext( sal_uInt16 nPrefix,
     672                 :            :                                             const ::rtl::OUString& rLName,
     673                 :            :                                             const ::com::sun::star::uno::Reference<
     674                 :            :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
     675                 :            : {
     676                 :          4 :     SvXMLImportContext *pContext(0);
     677                 :            : 
     678                 :          4 :     const SvXMLTokenMap& rTokenMap(GetScImport().GetFilterElemTokenMap());
     679      [ -  +  - ]:          4 :     switch( rTokenMap.Get( nPrefix, rLName ) )
     680                 :            :     {
     681                 :            :         case XML_TOK_FILTER_OR:
     682                 :            :         {
     683                 :            :             // not supported in StarOffice
     684                 :            :         }
     685                 :          0 :         break;
     686                 :            :         case XML_TOK_FILTER_CONDITION:
     687                 :            :         {
     688                 :            :             pContext = new ScXMLDPConditionContext( GetScImport(), nPrefix,
     689         [ +  - ]:          4 :                                                           rLName, xAttrList, pFilterContext);
     690                 :            :         }
     691                 :          4 :         break;
     692                 :            :     }
     693                 :            : 
     694         [ -  + ]:          4 :     if( !pContext )
     695         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     696                 :            : 
     697                 :          4 :     return pContext;
     698                 :            : }
     699                 :            : 
     700                 :          2 : void ScXMLDPAndContext::EndElement()
     701                 :            : {
     702                 :          2 :     pFilterContext->CloseConnection();
     703                 :          2 : }
     704                 :            : 
     705                 :          0 : ScXMLDPOrContext::ScXMLDPOrContext( ScXMLImport& rImport,
     706                 :            :                                       sal_uInt16 nPrfx,
     707                 :            :                                       const ::rtl::OUString& rLName,
     708                 :            :                                       const ::com::sun::star::uno::Reference<
     709                 :            :                                       ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
     710                 :            :                                         ScXMLDPFilterContext* pTempFilterContext) :
     711                 :            :     SvXMLImportContext( rImport, nPrfx, rLName ),
     712                 :          0 :     pFilterContext(pTempFilterContext)
     713                 :            : {
     714         [ #  # ]:          0 :     pFilterContext->OpenConnection(true);
     715                 :          0 : }
     716                 :            : 
     717                 :          0 : ScXMLDPOrContext::~ScXMLDPOrContext()
     718                 :            : {
     719         [ #  # ]:          0 : }
     720                 :            : 
     721                 :          0 : SvXMLImportContext *ScXMLDPOrContext::CreateChildContext( sal_uInt16 nPrefix,
     722                 :            :                                             const ::rtl::OUString& rLName,
     723                 :            :                                             const ::com::sun::star::uno::Reference<
     724                 :            :                                           ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
     725                 :            : {
     726                 :          0 :     SvXMLImportContext *pContext(0);
     727                 :            : 
     728                 :          0 :     const SvXMLTokenMap& rTokenMap(GetScImport().GetFilterElemTokenMap());
     729      [ #  #  # ]:          0 :     switch( rTokenMap.Get( nPrefix, rLName ) )
     730                 :            :     {
     731                 :            :         case XML_TOK_FILTER_AND:
     732                 :            :         {
     733                 :            :             pContext = new ScXMLDPAndContext( GetScImport(), nPrefix,
     734         [ #  # ]:          0 :                                                           rLName, xAttrList, pFilterContext);
     735                 :            :         }
     736                 :          0 :         break;
     737                 :            :         case XML_TOK_FILTER_CONDITION:
     738                 :            :         {
     739                 :            :             pContext = new ScXMLDPConditionContext( GetScImport(), nPrefix,
     740         [ #  # ]:          0 :                                                           rLName, xAttrList, pFilterContext);
     741                 :            :         }
     742                 :          0 :         break;
     743                 :            :     }
     744                 :            : 
     745         [ #  # ]:          0 :     if( !pContext )
     746         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
     747                 :            : 
     748                 :          0 :     return pContext;
     749                 :            : }
     750                 :            : 
     751                 :          0 : void ScXMLDPOrContext::EndElement()
     752                 :            : {
     753                 :          0 :     pFilterContext->CloseConnection();
     754                 :          0 : }
     755                 :            : 
     756                 :          4 : ScXMLDPConditionContext::ScXMLDPConditionContext( ScXMLImport& rImport,
     757                 :            :                                       sal_uInt16 nPrfx,
     758                 :            :                                       const ::rtl::OUString& rLName,
     759                 :            :                                       const ::com::sun::star::uno::Reference<
     760                 :            :                                       ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
     761                 :            :                                         ScXMLDPFilterContext* pTempFilterContext) :
     762                 :            :     SvXMLImportContext( rImport, nPrfx, rLName ),
     763                 :            :     pFilterContext(pTempFilterContext),
     764         [ +  - ]:          4 :     sDataType(GetXMLToken(XML_TEXT)),
     765                 :          8 :     bIsCaseSensitive(false)
     766                 :            : {
     767                 :            : 
     768 [ +  - ][ +  - ]:          4 :     sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
                 [ +  - ]
     769         [ +  - ]:          4 :     const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetFilterConditionAttrTokenMap());
     770         [ +  + ]:         20 :     for( sal_Int16 i=0; i < nAttrCount; ++i )
     771                 :            :     {
     772 [ +  - ][ +  - ]:         16 :         const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
     773                 :         16 :         rtl::OUString aLocalName;
     774                 :         16 :         sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
     775         [ +  - ]:         16 :                                             sAttrName, &aLocalName ));
     776 [ +  - ][ +  - ]:         16 :         const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
     777                 :            : 
     778 [ +  - ][ +  -  :         16 :         switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
             +  +  +  - ]
     779                 :            :         {
     780                 :            :             case XML_TOK_CONDITION_ATTR_FIELD_NUMBER :
     781                 :            :             {
     782                 :          4 :                 nField = sValue.toInt32();
     783                 :            :             }
     784                 :          4 :             break;
     785                 :            :             case XML_TOK_CONDITION_ATTR_CASE_SENSITIVE :
     786                 :            :             {
     787         [ #  # ]:          0 :                 bIsCaseSensitive = IsXMLToken(sValue, XML_TRUE);
     788                 :            :             }
     789                 :          0 :             break;
     790                 :            :             case XML_TOK_CONDITION_ATTR_DATA_TYPE :
     791                 :            :             {
     792                 :          4 :                 sDataType = sValue;
     793                 :            :             }
     794                 :          4 :             break;
     795                 :            :             case XML_TOK_CONDITION_ATTR_VALUE :
     796                 :            :             {
     797                 :          4 :                 sConditionValue = sValue;
     798                 :            :             }
     799                 :          4 :             break;
     800                 :            :             case XML_TOK_CONDITION_ATTR_OPERATOR :
     801                 :            :             {
     802                 :          4 :                 sOperator = sValue;
     803                 :            :             }
     804                 :          4 :             break;
     805                 :            :         }
     806                 :         16 :     }
     807                 :          4 : }
     808                 :            : 
     809                 :          4 : ScXMLDPConditionContext::~ScXMLDPConditionContext()
     810                 :            : {
     811         [ -  + ]:          8 : }
     812                 :            : 
     813                 :          0 : SvXMLImportContext *ScXMLDPConditionContext::CreateChildContext( sal_uInt16 nPrefix,
     814                 :            :                                             const ::rtl::OUString& rLName,
     815                 :            :                                             const ::com::sun::star::uno::Reference<
     816                 :            :                                         ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
     817                 :            : {
     818         [ #  # ]:          0 :     return new SvXMLImportContext( GetImport(), nPrefix, rLName );
     819                 :            : }
     820                 :            : 
     821                 :          4 : void ScXMLDPConditionContext::getOperatorXML(
     822                 :            :     const rtl::OUString sTempOperator, ScQueryOp& aFilterOperator, bool& bUseRegularExpressions) const
     823                 :            : {
     824                 :          4 :     bUseRegularExpressions = false;
     825         [ -  + ]:          4 :     if (IsXMLToken(sTempOperator, XML_MATCH))
     826                 :            :     {
     827                 :          0 :         bUseRegularExpressions = true;
     828                 :          0 :         aFilterOperator = SC_EQUAL;
     829                 :            :     }
     830         [ -  + ]:          4 :     else if (IsXMLToken(sTempOperator, XML_NOMATCH))
     831                 :            :     {
     832                 :          0 :         bUseRegularExpressions = true;
     833                 :          0 :         aFilterOperator = SC_NOT_EQUAL;
     834                 :            :     }
     835         [ -  + ]:          4 :     else if (sTempOperator.compareToAscii("=") == 0)
     836                 :          0 :         aFilterOperator = SC_EQUAL;
     837         [ -  + ]:          4 :     else if (sTempOperator.compareToAscii("!=") == 0)
     838                 :          0 :         aFilterOperator = SC_NOT_EQUAL;
     839         [ -  + ]:          4 :     else if (IsXMLToken(sTempOperator, XML_BOTTOM_PERCENT))
     840                 :          0 :         aFilterOperator = SC_BOTPERC;
     841         [ -  + ]:          4 :     else if (IsXMLToken(sTempOperator, XML_BOTTOM_VALUES))
     842                 :          0 :         aFilterOperator = SC_BOTVAL;
     843         [ +  + ]:          4 :     else if (sTempOperator.compareToAscii(">") == 0)
     844                 :          2 :         aFilterOperator = SC_GREATER;
     845         [ -  + ]:          2 :     else if (sTempOperator.compareToAscii(">=") == 0)
     846                 :          0 :         aFilterOperator = SC_GREATER_EQUAL;
     847         [ -  + ]:          2 :     else if (sTempOperator.compareToAscii("<") == 0)
     848                 :          0 :         aFilterOperator = SC_LESS;
     849         [ +  - ]:          2 :     else if (sTempOperator.compareToAscii("<=") == 0)
     850                 :          2 :         aFilterOperator = SC_LESS_EQUAL;
     851         [ #  # ]:          0 :     else if (IsXMLToken(sTempOperator, XML_TOP_PERCENT))
     852                 :          0 :         aFilterOperator = SC_TOPPERC;
     853         [ #  # ]:          0 :     else if (IsXMLToken(sTempOperator, XML_TOP_VALUES))
     854                 :          0 :         aFilterOperator = SC_TOPVAL;
     855                 :          4 : }
     856                 :            : 
     857                 :          4 : void ScXMLDPConditionContext::EndElement()
     858                 :            : {
     859         [ +  - ]:          4 :     ScQueryEntry aFilterField;
     860         [ +  + ]:          4 :     if (pFilterContext->GetConnection())
     861                 :          2 :         aFilterField.eConnect = SC_OR;
     862                 :            :     else
     863                 :          2 :         aFilterField.eConnect = SC_AND;
     864                 :          4 :     pFilterContext->SetIsCaseSensitive(bIsCaseSensitive);
     865 [ -  + ][ +  - ]:          4 :     if (IsXMLToken(sOperator, XML_EMPTY))
     866         [ #  # ]:          0 :         aFilterField.SetQueryByEmpty();
     867 [ +  - ][ -  + ]:          4 :     else if (IsXMLToken(sOperator, XML_NOEMPTY))
     868         [ #  # ]:          0 :         aFilterField.SetQueryByNonEmpty();
     869                 :            :     else
     870                 :            :     {
     871                 :          4 :         bool bUseRegularExpressions = false;
     872         [ +  - ]:          4 :         getOperatorXML(sOperator, aFilterField.eOp, bUseRegularExpressions);
     873                 :          4 :         pFilterContext->SetUseRegularExpressions(bUseRegularExpressions);
     874                 :          4 :         aFilterField.nField = nField;
     875         [ +  - ]:          4 :         ScQueryEntry::Item& rItem = aFilterField.GetQueryItem();
     876 [ +  - ][ +  - ]:          4 :         if (IsXMLToken(sDataType, XML_NUMBER))
     877                 :            :         {
     878                 :          4 :             rItem.mfVal = sConditionValue.toDouble();
     879                 :          4 :             rItem.maString = sConditionValue;
     880                 :          4 :             rItem.meType = ScQueryEntry::ByValue;
     881                 :            :         }
     882                 :            :         else
     883                 :            :         {
     884                 :          0 :             rItem.maString = sConditionValue;
     885                 :          0 :             rItem.meType = ScQueryEntry::ByString;
     886                 :          4 :             rItem.mfVal = 0.0;
     887                 :            :         }
     888                 :            :     }
     889 [ +  - ][ +  - ]:          4 :     pFilterContext->AddFilterField(aFilterField);
     890                 :          4 : }
     891                 :            : 
     892                 :            : 
     893                 :            : 
     894                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10