LCOV - code coverage report
Current view: top level - configmgr/source - xmldata.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 67 78 85.9 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 33 61 54.1 %

           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                 :            : #include <climits>
      24                 :            : #include <stack>
      25                 :            : 
      26                 :            : #include "com/sun/star/uno/Any.hxx"
      27                 :            : #include "com/sun/star/uno/Reference.hxx"
      28                 :            : #include "com/sun/star/uno/RuntimeException.hpp"
      29                 :            : #include "com/sun/star/uno/XInterface.hpp"
      30                 :            : #include "osl/file.hxx"
      31                 :            : #include "rtl/ref.hxx"
      32                 :            : #include "rtl/strbuf.hxx"
      33                 :            : #include "rtl/string.h"
      34                 :            : #include "rtl/ustrbuf.hxx"
      35                 :            : #include "rtl/ustring.h"
      36                 :            : #include "rtl/ustring.hxx"
      37                 :            : #include "sal/types.h"
      38                 :            : #include "xmlreader/span.hxx"
      39                 :            : #include "xmlreader/xmlreader.hxx"
      40                 :            : 
      41                 :            : #include "data.hxx"
      42                 :            : #include "groupnode.hxx"
      43                 :            : #include "localizedpropertynode.hxx"
      44                 :            : #include "localizedvaluenode.hxx"
      45                 :            : #include "node.hxx"
      46                 :            : #include "nodemap.hxx"
      47                 :            : #include "parsemanager.hxx"
      48                 :            : #include "parser.hxx"
      49                 :            : #include "propertynode.hxx"
      50                 :            : #include "setnode.hxx"
      51                 :            : #include "type.hxx"
      52                 :            : 
      53                 :            : namespace configmgr {
      54                 :            : 
      55                 :            : namespace xmldata {
      56                 :            : 
      57                 :            : namespace {
      58                 :            : 
      59                 :            : namespace css = com::sun::star;
      60                 :            : 
      61                 :            : }
      62                 :            : 
      63                 :    2687211 : Type parseType(
      64                 :            :     xmlreader::XmlReader const & reader, xmlreader::Span const & text)
      65                 :            : {
      66                 :            :     assert(text.is());
      67                 :    2687211 :     sal_Int32 i = rtl_str_indexOfChar_WithLength(text.begin, text.length, ':');
      68         [ +  - ]:    2687211 :     if (i >= 0) {
      69         [ +  - ]:    2687211 :         switch (reader.getNamespaceId(xmlreader::Span(text.begin, i))) {
              [ +  +  - ]
      70                 :            :         case ParseManager::NAMESPACE_OOR:
      71         [ +  + ]:      46925 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
      72                 :      46925 :                 equals(RTL_CONSTASCII_STRINGPARAM("any")))
      73                 :            :             {
      74                 :        972 :                 return TYPE_ANY;
      75         [ -  + ]:      45953 :             } else if (xmlreader::Span(
      76                 :      45953 :                            text.begin + i + 1, text.length - (i + 1)).
      77                 :      45953 :                        equals(RTL_CONSTASCII_STRINGPARAM("boolean-list")))
      78                 :            :             {
      79                 :          0 :                 return TYPE_BOOLEAN_LIST;
      80         [ -  + ]:      45953 :             } else if (xmlreader::Span(
      81                 :      45953 :                            text.begin + i + 1, text.length - (i + 1)).
      82                 :      45953 :                        equals(RTL_CONSTASCII_STRINGPARAM("short-list")))
      83                 :            :             {
      84                 :          0 :                 return TYPE_SHORT_LIST;
      85         [ +  + ]:      45953 :             } else if (xmlreader::Span(
      86                 :      45953 :                            text.begin + i + 1, text.length - (i + 1)).
      87                 :      45953 :                        equals(RTL_CONSTASCII_STRINGPARAM("int-list")))
      88                 :            :             {
      89                 :        972 :                 return TYPE_INT_LIST;
      90         [ +  + ]:      44981 :             } else if (xmlreader::Span(
      91                 :      44981 :                            text.begin + i + 1, text.length - (i + 1)).
      92                 :      44981 :                        equals(RTL_CONSTASCII_STRINGPARAM("long-list")))
      93                 :            :             {
      94                 :        324 :                 return TYPE_LONG_LIST;
      95         [ -  + ]:      44657 :             } else if (xmlreader::Span(
      96                 :      44657 :                            text.begin + i + 1, text.length - (i + 1)).
      97                 :      44657 :                        equals(RTL_CONSTASCII_STRINGPARAM("double-list")))
      98                 :            :             {
      99                 :          0 :                 return TYPE_DOUBLE_LIST;
     100         [ +  - ]:      44657 :             } else if (xmlreader::Span(
     101                 :      44657 :                            text.begin + i + 1, text.length - (i + 1)).
     102                 :      44657 :                        equals(RTL_CONSTASCII_STRINGPARAM("string-list")))
     103                 :            :             {
     104                 :      44657 :                 return TYPE_STRING_LIST;
     105         [ #  # ]:          0 :             } else if (xmlreader::Span(
     106                 :          0 :                            text.begin + i + 1, text.length - (i + 1)).
     107                 :          0 :                        equals(RTL_CONSTASCII_STRINGPARAM("hexBinary-list")))
     108                 :            :             {
     109                 :          0 :                 return TYPE_HEXBINARY_LIST;
     110                 :            :             }
     111                 :          0 :             break;
     112                 :            :         case ParseManager::NAMESPACE_XS:
     113         [ +  + ]:    2640286 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
     114                 :    2640286 :                 equals(RTL_CONSTASCII_STRINGPARAM("boolean")))
     115                 :            :             {
     116                 :     620872 :                 return TYPE_BOOLEAN;
     117         [ +  + ]:    2019414 :             } else if (xmlreader::Span(
     118                 :    2019414 :                            text.begin + i + 1, text.length - (i + 1)).
     119                 :    2019414 :                        equals(RTL_CONSTASCII_STRINGPARAM("short")))
     120                 :            :             {
     121                 :      36550 :                 return TYPE_SHORT;
     122         [ +  + ]:    1982864 :             } else if (xmlreader::Span(
     123                 :    1982864 :                            text.begin + i + 1, text.length - (i + 1)).
     124                 :    1982864 :                        equals(RTL_CONSTASCII_STRINGPARAM("int")))
     125                 :            :             {
     126                 :     551953 :                 return TYPE_INT;
     127         [ +  + ]:    1430911 :             } else if (xmlreader::Span(
     128                 :    1430911 :                            text.begin + i + 1, text.length - (i + 1)).
     129                 :    1430911 :                        equals(RTL_CONSTASCII_STRINGPARAM("long")))
     130                 :            :             {
     131                 :       8100 :                 return TYPE_LONG;
     132         [ +  + ]:    1422811 :             } else if (xmlreader::Span(
     133                 :    1422811 :                            text.begin + i + 1, text.length - (i + 1)).
     134                 :    1422811 :                        equals(RTL_CONSTASCII_STRINGPARAM("double")))
     135                 :            :             {
     136                 :      15952 :                 return TYPE_DOUBLE;
     137         [ +  + ]:    1406859 :             } else if (xmlreader::Span(
     138                 :    1406859 :                            text.begin + i + 1, text.length - (i + 1)).
     139                 :    1406859 :                        equals(RTL_CONSTASCII_STRINGPARAM("string")))
     140                 :            :             {
     141                 :    1405039 :                 return TYPE_STRING;
     142         [ +  - ]:       1820 :             } else if (xmlreader::Span(
     143                 :       1820 :                            text.begin + i + 1, text.length - (i + 1)).
     144                 :       1820 :                        equals(RTL_CONSTASCII_STRINGPARAM("hexBinary")))
     145                 :            :             {
     146                 :       1820 :                 return TYPE_HEXBINARY;
     147                 :            :             }
     148                 :          0 :             break;
     149                 :            :         default:
     150                 :          0 :             break;
     151                 :            :         }
     152                 :            :     }
     153                 :            :     throw css::uno::RuntimeException(
     154                 :            :         (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("invalid type ")) +
     155                 :            :          text.convertFromUtf8()),
     156 [ #  # ][ #  # ]:    2687211 :         css::uno::Reference< css::uno::XInterface >());
                 [ #  # ]
     157                 :            : }
     158                 :            : 
     159                 :    1113585 : bool parseBoolean(xmlreader::Span const & text) {
     160                 :            :     assert(text.is());
     161         [ +  + ]:    1113585 :     if (text.equals(RTL_CONSTASCII_STRINGPARAM("true"))) {
     162                 :     668341 :         return true;
     163                 :            :     }
     164         [ +  - ]:     445244 :     if (text.equals(RTL_CONSTASCII_STRINGPARAM("false"))) {
     165                 :     445244 :         return false;
     166                 :            :     }
     167                 :            :     throw css::uno::RuntimeException(
     168                 :            :         (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("invalid boolean ")) +
     169                 :            :          text.convertFromUtf8()),
     170 [ #  # ][ #  # ]:    1113585 :         css::uno::Reference< css::uno::XInterface >());
                 [ #  # ]
     171                 :            : }
     172                 :            : 
     173                 :    2605819 : rtl::OUString parseTemplateReference(
     174                 :            :     rtl::OUString const & component, bool hasNodeType,
     175                 :            :     rtl::OUString const & nodeType, rtl::OUString const * defaultTemplateName)
     176                 :            : {
     177         [ +  + ]:    2605819 :     if (!hasNodeType) {
     178         [ +  - ]:    2517837 :         if (defaultTemplateName != 0) {
     179                 :    2517837 :             return *defaultTemplateName;
     180                 :            :         }
     181                 :            :         throw css::uno::RuntimeException(
     182                 :            :             rtl::OUString(
     183                 :            :                 RTL_CONSTASCII_USTRINGPARAM("missing node-type attribute")),
     184 [ #  # ][ #  # ]:          0 :             css::uno::Reference< css::uno::XInterface >());
     185                 :            :     }
     186                 :    2605819 :     return Data::fullTemplateName(component, nodeType);
     187                 :            : }
     188                 :            : 
     189                 :            : }
     190                 :            : 
     191                 :            : }
     192                 :            : 
     193                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10