LCOV - code coverage report
Current view: top level - configmgr/source - valueparser.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 155 203 76.4 %
Date: 2012-08-25 Functions: 28 38 73.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 172 593 29.0 %

           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 "sal/config.h"
      21                 :            : 
      22                 :            : #include <cassert>
      23                 :            : 
      24                 :            : #include "com/sun/star/uno/Any.hxx"
      25                 :            : #include "com/sun/star/uno/Reference.hxx"
      26                 :            : #include "com/sun/star/uno/RuntimeException.hpp"
      27                 :            : #include "com/sun/star/uno/Sequence.hxx"
      28                 :            : #include "com/sun/star/uno/XInterface.hpp"
      29                 :            : #include "comphelper/sequenceasvector.hxx"
      30                 :            : #include "rtl/string.h"
      31                 :            : #include "rtl/string.hxx"
      32                 :            : #include "rtl/ustring.h"
      33                 :            : #include "rtl/ustring.hxx"
      34                 :            : #include "sal/types.h"
      35                 :            : #include "xmlreader/span.hxx"
      36                 :            : #include "xmlreader/xmlreader.hxx"
      37                 :            : 
      38                 :            : #include "localizedvaluenode.hxx"
      39                 :            : #include "node.hxx"
      40                 :            : #include "nodemap.hxx"
      41                 :            : #include "parsemanager.hxx"
      42                 :            : #include "propertynode.hxx"
      43                 :            : #include "type.hxx"
      44                 :            : #include "valueparser.hxx"
      45                 :            : #include "xmldata.hxx"
      46                 :            : 
      47                 :            : namespace configmgr {
      48                 :            : 
      49                 :            : namespace {
      50                 :            : 
      51                 :            : namespace css = com::sun::star;
      52                 :            : 
      53                 :      19600 : bool parseHexDigit(char c, int * value) {
      54                 :            :     assert(value != 0);
      55 [ +  - ][ +  + ]:      19600 :     if (c >= '0' && c <= '9') {
      56                 :       5684 :         *value = c - '0';
      57                 :       5684 :         return true;
      58                 :            :     }
      59 [ +  - ][ +  + ]:      13916 :     if (c >= 'A' && c <= 'F') {
      60                 :      10290 :         *value = c - 'A' + 10;
      61                 :      10290 :         return true;
      62                 :            :     }
      63 [ +  - ][ +  - ]:       3626 :     if (c >= 'a' && c <= 'f') {
      64                 :       3626 :         *value = c - 'a' + 10;
      65                 :       3626 :         return true;
      66                 :            :     }
      67                 :      19600 :     return false;
      68                 :            : }
      69                 :            : 
      70                 :     704854 : bool parseValue(xmlreader::Span const & text, sal_Bool * value) {
      71                 :            :     assert(text.is() && value != 0);
      72   [ +  +  -  + ]:    1006540 :     if (text.equals(RTL_CONSTASCII_STRINGPARAM("true")) ||
                 [ +  + ]
      73                 :     301686 :         text.equals(RTL_CONSTASCII_STRINGPARAM("1")))
      74                 :            :     {
      75                 :     403168 :         *value = true;
      76                 :     403168 :         return true;
      77                 :            :     }
      78   [ -  +  #  # ]:     301686 :     if (text.equals(RTL_CONSTASCII_STRINGPARAM("false")) ||
                 [ +  - ]
      79                 :          0 :         text.equals(RTL_CONSTASCII_STRINGPARAM("0")))
      80                 :            :     {
      81                 :     301686 :         *value = false;
      82                 :     301686 :         return true;
      83                 :            :     }
      84                 :     704854 :     return false;
      85                 :            : }
      86                 :            : 
      87                 :      30583 : bool parseValue(xmlreader::Span const & text, sal_Int16 * value) {
      88                 :            :     assert(text.is() && value != 0);
      89                 :            :     // For backwards compatibility, support hexadecimal values:
      90                 :            :     sal_Int32 n =
      91                 :            :         rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
      92                 :            :             text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"),
      93                 :      30583 :             RTL_CONSTASCII_LENGTH("0X")) == 0 ?
      94                 :            :         rtl::OString(
      95                 :            :             text.begin + RTL_CONSTASCII_LENGTH("0X"),
      96         [ -  + ]:      30583 :             text.length - RTL_CONSTASCII_LENGTH("0X")).toInt32(16) :
      97 [ +  - ][ -  + ]:      30583 :         rtl::OString(text.begin, text.length).toInt32();
      98                 :            :         //TODO: check valid lexical representation
      99 [ +  - ][ +  - ]:      30583 :     if (n >= SAL_MIN_INT16 && n <= SAL_MAX_INT16) {
     100                 :      30583 :         *value = static_cast< sal_Int16 >(n);
     101                 :      30583 :         return true;
     102                 :            :     }
     103                 :      30583 :     return false;
     104                 :            : }
     105                 :            : 
     106                 :    1086759 : bool parseValue(xmlreader::Span const & text, sal_Int32 * value) {
     107                 :            :     assert(text.is() && value != 0);
     108                 :            :     // For backwards compatibility, support hexadecimal values:
     109                 :            :     *value =
     110                 :            :         rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
     111                 :            :             text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"),
     112                 :    1086759 :             RTL_CONSTASCII_LENGTH("0X")) == 0 ?
     113                 :            :         rtl::OString(
     114                 :            :             text.begin + RTL_CONSTASCII_LENGTH("0X"),
     115         [ -  + ]:    1086759 :             text.length - RTL_CONSTASCII_LENGTH("0X")).toInt32(16) :
     116 [ +  - ][ -  + ]:    1086759 :         rtl::OString(text.begin, text.length).toInt32();
     117                 :            :         //TODO: check valid lexical representation
     118                 :    1086759 :     return true;
     119                 :            : }
     120                 :            : 
     121                 :      13006 : bool parseValue(xmlreader::Span const & text, sal_Int64 * value) {
     122                 :            :     assert(text.is() && value != 0);
     123                 :            :     // For backwards compatibility, support hexadecimal values:
     124                 :            :     *value =
     125                 :            :         rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
     126                 :            :             text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"),
     127                 :      13006 :             RTL_CONSTASCII_LENGTH("0X")) == 0 ?
     128                 :            :         rtl::OString(
     129                 :            :             text.begin + RTL_CONSTASCII_LENGTH("0X"),
     130         [ -  + ]:      13006 :             text.length - RTL_CONSTASCII_LENGTH("0X")).toInt64(16) :
     131 [ +  - ][ -  + ]:      13006 :         rtl::OString(text.begin, text.length).toInt64();
     132                 :            :         //TODO: check valid lexical representation
     133                 :      13006 :     return true;
     134                 :            : }
     135                 :            : 
     136                 :      19524 : bool parseValue(xmlreader::Span const & text, double * value) {
     137                 :            :     assert(text.is() && value != 0);
     138                 :      19524 :     *value = rtl::OString(text.begin, text.length).toDouble();
     139                 :            :         //TODO: check valid lexical representation
     140                 :      19524 :     return true;
     141                 :            : }
     142                 :            : 
     143                 :    5151836 : bool parseValue(xmlreader::Span const & text, rtl::OUString * value) {
     144                 :            :     assert(text.is() && value != 0);
     145                 :    5151836 :     *value = text.convertFromUtf8();
     146                 :    5151836 :     return true;
     147                 :            : }
     148                 :            : 
     149                 :       3234 : bool parseValue(
     150                 :            :     xmlreader::Span const & text, css::uno::Sequence< sal_Int8 > * value)
     151                 :            : {
     152                 :            :     assert(text.is() && value != 0);
     153         [ -  + ]:       3234 :     if ((text.length & 1) != 0) {
     154                 :          0 :         return false;
     155                 :            :     }
     156         [ +  - ]:       3234 :     comphelper::SequenceAsVector< sal_Int8 > seq;
     157         [ +  + ]:      13034 :     for (sal_Int32 i = 0; i != text.length;) {
     158                 :            :         int n1;
     159                 :            :         int n2;
     160   [ +  -  -  + ]:      19600 :         if (!parseHexDigit(text.begin[i++], &n1) ||
                 [ -  + ]
     161                 :       9800 :             !parseHexDigit(text.begin[i++], &n2))
     162                 :            :         {
     163                 :          0 :             return false;
     164                 :            :         }
     165         [ +  - ]:       9800 :         seq.push_back(static_cast< sal_Int8 >((n1 << 4) | n2));
     166                 :            :     }
     167 [ +  - ][ +  - ]:       3234 :     *value = seq.getAsConstList();
                 [ +  - ]
     168                 :       3234 :     return true;
     169                 :            : }
     170                 :            : 
     171                 :    6447357 : template< typename T > css::uno::Any parseSingleValue(
     172                 :            :     xmlreader::Span const & text)
     173                 :            : {
     174         [ +  - ]:    4611587 :     T val;
     175         [ +  - ]:    6447357 :     if (!parseValue(text, &val)) {
           [ -  +  +  - ]
         [ -  + ][ -  + ]
         [ +  - ][ -  + ]
         [ +  - ][ -  + ]
         [ +  - ][ -  + ]
         [ +  - ][ -  + ]
     176                 :            :         throw css::uno::RuntimeException(
     177                 :            :             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("invalid value")),
     178 [ #  # ][ #  # ]:          0 :             css::uno::Reference< css::uno::XInterface >());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     179                 :            :     }
     180 [ +  - ][ +  - ]:    6447357 :     return css::uno::makeAny(val);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     181                 :            : }
     182                 :            : 
     183                 :     198133 : template< typename T > css::uno::Any parseListValue(
     184                 :            :     rtl::OString const & separator, xmlreader::Span const & text)
     185                 :            : {
     186 [ #  # ][ +  - ]:     198133 :     comphelper::SequenceAsVector< T > seq;
         [ #  # ][ +  - ]
         [ +  - ][ #  # ]
                 [ #  # ]
     187                 :     198133 :     xmlreader::Span sep;
     188   [ #  #  +  +  :     198133 :     if (separator.isEmpty()) {
          #  #  +  -  +  
             -  #  #  #  
                      # ]
     189                 :     171850 :         sep = xmlreader::Span(RTL_CONSTASCII_STRINGPARAM(" "));
     190                 :            :     } else {
     191                 :      26283 :         sep = xmlreader::Span(separator.getStr(), separator.getLength());
     192                 :            :     }
     193 [ #  # ][ +  + ]:     198133 :     if (text.length != 0) {
         [ #  # ][ +  - ]
         [ +  - ][ #  # ]
                 [ #  # ]
     194                 :     730888 :         for (xmlreader::Span t(text);;) {
     195                 :            :             sal_Int32 i = rtl_str_indexOfStr_WithLength(
     196                 :     562439 :                 t.begin, t.length, sep.begin, sep.length);
     197         [ #  # ]:     543483 :             T val;
     198 [ #  # ][ #  # ]:     562439 :             if (!parseValue(
           [ #  #  +  + ]
                 [ +  - ]
           [ -  +  #  # ]
           [ #  #  +  + ]
                 [ +  - ]
           [ -  +  +  + ]
                 [ +  - ]
           [ -  +  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
         [ #  # ][ #  # ]
     199                 :            :                     xmlreader::Span(t.begin, i == -1 ? t.length : i), &val))
     200                 :            :             {
     201                 :            :                 throw css::uno::RuntimeException(
     202                 :            :                     rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("invalid value")),
     203 [ #  # ][ #  # ]:          0 :                     css::uno::Reference< css::uno::XInterface >());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     204                 :            :             }
     205 [ #  # ][ +  - ]:     562439 :             seq.push_back(val);
         [ #  # ][ +  - ]
         [ +  - ][ #  # ]
                 [ #  # ]
     206 [ #  # ][ +  + ]:     562439 :             if (i < 0) {
         [ #  # ][ +  + ]
         [ +  + ][ #  # ]
                 [ #  # ]
     207                 :            :                 break;
     208                 :            :             }
     209                 :     393990 :             t.begin += i + sep.length;
     210 [ #  # ][ #  # ]:     543483 :             t.length -= i + sep.length;
                 [ +  + ]
     211                 :            :         }
     212                 :            :     }
     213 [ #  # ][ #  # ]:     198133 :     return css::uno::makeAny(seq.getAsConstList());
         [ #  # ][ +  - ]
         [ +  - ][ +  - ]
         [ #  # ][ #  # ]
         [ #  # ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     214                 :            : }
     215                 :            : 
     216                 :    6645490 : css::uno::Any parseValue(
     217                 :            :     rtl::OString const & separator, xmlreader::Span const & text, Type type)
     218                 :            : {
     219   [ -  +  +  +  :    6645490 :     switch (type) {
          +  +  +  +  -  
          -  +  +  -  +  
                   -  - ]
     220                 :            :     case TYPE_ANY:
     221                 :            :         throw css::uno::RuntimeException(
     222                 :            :             rtl::OUString(
     223                 :            :                 RTL_CONSTASCII_USTRINGPARAM("invalid value of type any")),
     224 [ #  # ][ #  # ]:          0 :             css::uno::Reference< css::uno::XInterface >());
     225                 :            :     case TYPE_BOOLEAN:
     226                 :     704854 :         return parseSingleValue< sal_Bool >(text);
     227                 :            :     case TYPE_SHORT:
     228                 :      30583 :         return parseSingleValue< sal_Int16 >(text);
     229                 :            :     case TYPE_INT:
     230                 :    1071691 :         return parseSingleValue< sal_Int32 >(text);
     231                 :            :     case TYPE_LONG:
     232                 :       9118 :         return parseSingleValue< sal_Int64 >(text);
     233                 :            :     case TYPE_DOUBLE:
     234                 :      19524 :         return parseSingleValue< double >(text);
     235                 :            :     case TYPE_STRING:
     236                 :    4608353 :         return parseSingleValue< rtl::OUString >(text);
     237                 :            :     case TYPE_HEXBINARY:
     238                 :       3234 :         return parseSingleValue< css::uno::Sequence< sal_Int8 > >(text);
     239                 :            :     case TYPE_BOOLEAN_LIST:
     240                 :          0 :         return parseListValue< sal_Bool >(separator, text);
     241                 :            :     case TYPE_SHORT_LIST:
     242                 :          0 :         return parseListValue< sal_Int16 >(separator, text);
     243                 :            :     case TYPE_INT_LIST:
     244                 :        972 :         return parseListValue< sal_Int32 >(separator, text);
     245                 :            :     case TYPE_LONG_LIST:
     246                 :        324 :         return parseListValue< sal_Int64 >(separator, text);
     247                 :            :     case TYPE_DOUBLE_LIST:
     248                 :          0 :         return parseListValue< double >(separator, text);
     249                 :            :     case TYPE_STRING_LIST:
     250                 :     196837 :         return parseListValue< rtl::OUString >(separator, text);
     251                 :            :     case TYPE_HEXBINARY_LIST:
     252                 :            :         return parseListValue< css::uno::Sequence< sal_Int8 > >(
     253                 :          0 :             separator, text);
     254                 :            :     default:
     255                 :            :         assert(false);
     256                 :            :         throw css::uno::RuntimeException(
     257                 :            :             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("this cannot happen")),
     258 [ #  # ][ #  # ]:    6645490 :             css::uno::Reference< css::uno::XInterface >());
     259                 :            :     }
     260                 :            : }
     261                 :            : 
     262                 :            : }
     263                 :            : 
     264 [ +  - ][ +  - ]:      82025 : ValueParser::ValueParser(int layer): layer_(layer) {}
     265                 :            : 
     266 [ +  - ][ +  - ]:      82025 : ValueParser::~ValueParser() {}
     267                 :            : 
     268                 :   44147343 : xmlreader::XmlReader::Text ValueParser::getTextMode() const {
     269         [ +  + ]:   44147343 :     if (node_.is()) {
     270      [ +  +  - ]:   13002634 :         switch (state_) {
     271                 :            :         case STATE_TEXT:
     272         [ +  + ]:   12934546 :             if (!items_.empty()) {
     273                 :      34044 :                 break;
     274                 :            :             }
     275                 :            :             // fall through
     276                 :            :         case STATE_IT:
     277                 :            :             return
     278                 :            :                 (type_ == TYPE_STRING || type_ == TYPE_STRING_LIST ||
     279                 :    3680276 :                  !separator_.isEmpty())
     280                 :            :                 ? xmlreader::XmlReader::TEXT_RAW
     281         [ +  + ]:   16648866 :                 : xmlreader::XmlReader::TEXT_NORMALIZED;
           [ +  +  -  + ]
     282                 :            :         default:
     283                 :      34044 :             break;
     284                 :            :         }
     285                 :            :     }
     286                 :   44147343 :     return xmlreader::XmlReader::TEXT_NONE;
     287                 :            : }
     288                 :            : 
     289                 :   18918730 : bool ValueParser::startElement(
     290                 :            :     xmlreader::XmlReader & reader, int nsId, xmlreader::Span const & name)
     291                 :            : {
     292         [ +  + ]:   18918730 :     if (!node_.is()) {
     293                 :   18884686 :         return false;
     294                 :            :     }
     295      [ +  -  - ]:      34044 :     switch (state_) {
     296                 :            :     case STATE_TEXT:
     297   [ +  -  +  -  :     136176 :         if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
             +  -  +  - ]
                 [ +  - ]
     298                 :      34044 :             name.equals(RTL_CONSTASCII_STRINGPARAM("it")) &&
     299                 :      68088 :             isListType(type_) && separator_.isEmpty())
     300                 :            :         {
     301                 :      34044 :             pad_.clear();
     302                 :            :                 // before first <it>, characters are not ignored; assume they
     303                 :            :                 // are only whitespace
     304                 :      34044 :             state_ = STATE_IT;
     305                 :      34044 :             return true;
     306                 :            :         }
     307                 :            :         // fall through
     308                 :            :     case STATE_IT:
     309   [ #  #  #  # ]:          0 :         if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
         [ #  # ][ #  # ]
                 [ #  # ]
     310                 :          0 :             name.equals(RTL_CONSTASCII_STRINGPARAM("unicode")) &&
     311                 :            :             (type_ == TYPE_STRING || type_ == TYPE_STRING_LIST))
     312                 :            :         {
     313                 :          0 :             sal_Int32 scalar = -1;
     314                 :          0 :             for (;;) {
     315                 :            :                 int attrNsId;
     316                 :          0 :                 xmlreader::Span attrLn;
     317 [ #  # ][ #  # ]:          0 :                 if (!reader.nextAttribute(&attrNsId, &attrLn)) {
     318                 :            :                     break;
     319                 :            :                 }
     320   [ #  #  #  # ]:          0 :                 if (attrNsId == ParseManager::NAMESPACE_OOR &&
                 [ #  # ]
     321                 :          0 :                     attrLn.equals(RTL_CONSTASCII_STRINGPARAM("scalar")))
     322                 :            :                 {
     323 [ #  # ][ #  # ]:          0 :                     if (!parseValue(reader.getAttributeValue(true), &scalar)) {
                 [ #  # ]
     324                 :          0 :                         scalar = -1;
     325                 :            :                     }
     326                 :            :                     break;
     327                 :            :                 }
     328                 :            :             }
     329 [ #  # ][ #  # ]:          0 :             if (scalar >= 0 && scalar < 0x20 && scalar != 0x09 &&
         [ #  # ][ #  # ]
                 [ #  # ]
     330                 :            :                 scalar != 0x0A && scalar != 0x0D)
     331                 :            :             {
     332                 :          0 :                 char c = static_cast< char >(scalar);
     333         [ #  # ]:          0 :                 pad_.add(&c, 1);
     334         [ #  # ]:          0 :             } else if (scalar == 0xFFFE) {
     335         [ #  # ]:          0 :                 pad_.add(RTL_CONSTASCII_STRINGPARAM("\xEF\xBF\xBE"));
     336         [ #  # ]:          0 :             } else if (scalar == 0xFFFF) {
     337         [ #  # ]:          0 :                 pad_.add(RTL_CONSTASCII_STRINGPARAM("\xEF\xBF\xBF"));
     338                 :            :             } else {
     339                 :            :                 throw css::uno::RuntimeException(
     340                 :            :                     (rtl::OUString(
     341                 :            :                         RTL_CONSTASCII_USTRINGPARAM(
     342                 :            :                             "bad unicode scalar attribute in ")) +
     343                 :            :                      reader.getUrl()),
     344 [ #  # ][ #  # ]:          0 :                     css::uno::Reference< css::uno::XInterface >());
                 [ #  # ]
     345                 :            :             }
     346                 :          0 :             state_ = State(state_ + 1);
     347                 :          0 :             return true;
     348                 :            :         }
     349                 :          0 :         break;
     350                 :            :     default:
     351                 :          0 :         break;
     352                 :            :     }
     353                 :            :     throw css::uno::RuntimeException(
     354                 :            :         (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad member <")) +
     355                 :            :          name.convertFromUtf8() +
     356                 :            :          rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("> in ")) + reader.getUrl()),
     357 [ #  # ][ #  # ]:   18918730 :         css::uno::Reference< css::uno::XInterface >());
         [ #  # ][ #  # ]
                 [ #  # ]
     358                 :            : }
     359                 :            : 
     360                 :   18918730 : bool ValueParser::endElement() {
     361         [ +  + ]:   18918730 :     if (!node_.is()) {
     362                 :   12258996 :         return false;
     363                 :            :     }
     364   [ +  -  +  - ]:    6659734 :     switch (state_) {
     365                 :            :     case STATE_TEXT:
     366                 :            :         {
     367                 :    6625690 :             css::uno::Any value;
     368         [ +  + ]:    6625690 :             if (items_.empty()) {
     369 [ +  - ][ +  - ]:    6611446 :                 value = parseValue(separator_, pad_.get(), type_);
     370         [ +  - ]:    6611446 :                 pad_.clear();
     371                 :            :             } else {
     372   [ -  -  -  -  :      14244 :                 switch (type_) {
             -  +  -  - ]
     373                 :            :                 case TYPE_BOOLEAN_LIST:
     374         [ #  # ]:          0 :                     value = convertItems< sal_Bool >();
     375                 :          0 :                     break;
     376                 :            :                 case TYPE_SHORT_LIST:
     377         [ #  # ]:          0 :                     value = convertItems< sal_Int16 >();
     378                 :          0 :                     break;
     379                 :            :                 case TYPE_INT_LIST:
     380         [ #  # ]:          0 :                     value = convertItems< sal_Int32 >();
     381                 :          0 :                     break;
     382                 :            :                 case TYPE_LONG_LIST:
     383         [ #  # ]:          0 :                     value = convertItems< sal_Int64 >();
     384                 :          0 :                     break;
     385                 :            :                 case TYPE_DOUBLE_LIST:
     386         [ #  # ]:          0 :                     value = convertItems< double >();
     387                 :          0 :                     break;
     388                 :            :                 case TYPE_STRING_LIST:
     389         [ +  - ]:      14244 :                     value = convertItems< rtl::OUString >();
     390                 :      14244 :                     break;
     391                 :            :                 case TYPE_HEXBINARY_LIST:
     392         [ #  # ]:          0 :                     value = convertItems< css::uno::Sequence< sal_Int8 > >();
     393                 :          0 :                     break;
     394                 :            :                 default:
     395                 :            :                     assert(false); // this cannot happen
     396                 :          0 :                     break;
     397                 :            :                 }
     398                 :      14244 :                 items_.clear();
     399                 :            :             }
     400         [ +  - ]:    6625690 :             switch (node_->kind()) {
              [ +  +  - ]
     401                 :            :             case Node::KIND_PROPERTY:
     402                 :    4792984 :                 dynamic_cast< PropertyNode * >(node_.get())->setValue(
     403 [ +  - ][ -  + ]:    4792984 :                     layer_, value);
     404                 :    4792984 :                 break;
     405                 :            :             case Node::KIND_LOCALIZED_PROPERTY:
     406                 :            :                 {
     407         [ +  - ]:    1832706 :                     NodeMap & members = node_->getMembers();
     408         [ +  - ]:    1832706 :                     NodeMap::iterator i(members.find(localizedName_));
     409         [ +  + ]:    1832706 :                     if (i == members.end()) {
     410                 :            :                         members.insert(
     411                 :            :                             NodeMap::value_type(
     412                 :            :                                 localizedName_,
     413 [ +  - ][ +  - ]:    1832302 :                                 new LocalizedValueNode(layer_, value)));
         [ +  - ][ +  - ]
                 [ +  - ]
     414                 :            :                     } else {
     415                 :        404 :                         dynamic_cast< LocalizedValueNode * >(i->second.get())->
     416 [ +  - ][ -  + ]:        404 :                             setValue(layer_, value);
     417                 :            :                     }
     418                 :            :                 }
     419                 :    1832706 :                 break;
     420                 :            :             default:
     421                 :            :                 assert(false); // this cannot happen
     422                 :          0 :                 break;
     423                 :            :             }
     424                 :    6625690 :             separator_ = rtl::OString();
     425         [ +  - ]:    6625690 :             node_.clear();
     426                 :            :         }
     427                 :    6625690 :         break;
     428                 :            :     case STATE_TEXT_UNICODE:
     429                 :            :     case STATE_IT_UNICODE:
     430                 :          0 :         state_ = State(state_ - 1);
     431                 :          0 :         break;
     432                 :            :     case STATE_IT:
     433                 :            :         items_.push_back(
     434 [ +  - ][ +  - ]:      34044 :             parseValue(rtl::OString(), pad_.get(), elementType(type_)));
     435                 :      34044 :         pad_.clear();
     436                 :      34044 :         state_ = STATE_TEXT;
     437                 :      34044 :         break;
     438                 :            :     }
     439                 :   18918730 :     return true;
     440                 :            : }
     441                 :            : 
     442                 :    6308856 : void ValueParser::characters(xmlreader::Span const & text) {
     443         [ +  - ]:    6308856 :     if (node_.is()) {
     444                 :            :         assert(state_ == STATE_TEXT || state_ == STATE_IT);
     445                 :    6308856 :         pad_.add(text.begin, text.length);
     446                 :            :     }
     447                 :    6308856 : }
     448                 :            : 
     449                 :    6625690 : void ValueParser::start(
     450                 :            :     rtl::Reference< Node > const & node, rtl::OUString const & localizedName)
     451                 :            : {
     452                 :            :     assert(node.is() && !node_.is());
     453                 :    6625690 :     node_ = node;
     454                 :    6625690 :     localizedName_ = localizedName;
     455                 :    6625690 :     state_ = STATE_TEXT;
     456                 :    6625690 : }
     457                 :            : 
     458                 :   22565268 : int ValueParser::getLayer() const {
     459                 :   22565268 :     return layer_;
     460                 :            : }
     461                 :            : 
     462                 :      14244 : template< typename T > css::uno::Any ValueParser::convertItems() {
     463 [ #  # ][ +  - ]:      14244 :     css::uno::Sequence< T > seq(items_.size());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     464 [ #  # ][ +  + ]:      48288 :     for (sal_Int32 i = 0; i < seq.getLength(); ++i) {
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     465 [ #  # ][ #  # ]:      34044 :         bool ok = (items_[i] >>= seq[i]);
         [ +  - ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     466                 :            :         assert(ok);
     467                 :            :         (void) ok; // avoid warnings
     468                 :            :     }
     469 [ #  # ][ #  # ]:      14244 :     return css::uno::makeAny(seq);
         [ +  - ][ +  - ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     470                 :            : }
     471                 :            : 
     472                 :            : }
     473                 :            : 
     474                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10