LCOV - code coverage report
Current view: top level - configmgr/source - xmldata.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 65 78 83.3 %
Date: 2014-11-03 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * 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/string.h>
      33             : #include <rtl/ustring.hxx>
      34             : #include <sal/types.h>
      35             : #include <xmlreader/span.hxx>
      36             : #include <xmlreader/xmlreader.hxx>
      37             : 
      38             : #include "data.hxx"
      39             : #include "groupnode.hxx"
      40             : #include "localizedpropertynode.hxx"
      41             : #include "localizedvaluenode.hxx"
      42             : #include "node.hxx"
      43             : #include "nodemap.hxx"
      44             : #include "parsemanager.hxx"
      45             : #include "parser.hxx"
      46             : #include "propertynode.hxx"
      47             : #include "setnode.hxx"
      48             : #include "type.hxx"
      49             : #include "xmldata.hxx"
      50             : 
      51             : namespace configmgr {
      52             : 
      53             : namespace xmldata {
      54             : 
      55     3345044 : Type parseType(
      56             :     xmlreader::XmlReader const & reader, xmlreader::Span const & text)
      57             : {
      58             :     assert(text.is());
      59     3345044 :     sal_Int32 i = rtl_str_indexOfChar_WithLength(text.begin, text.length, ':');
      60     3345044 :     if (i >= 0) {
      61     3345044 :         switch (reader.getNamespaceId(xmlreader::Span(text.begin, i))) {
      62             :         case ParseManager::NAMESPACE_OOR:
      63      205968 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
      64      205968 :                 equals("any"))
      65             :             {
      66        1143 :                 return TYPE_ANY;
      67      100698 :             } else if (xmlreader::Span(
      68      100698 :                            text.begin + i + 1, text.length - (i + 1)).
      69      201396 :                        equals("boolean-list"))
      70             :             {
      71           0 :                 return TYPE_BOOLEAN_LIST;
      72      100698 :             } else if (xmlreader::Span(
      73      100698 :                            text.begin + i + 1, text.length - (i + 1)).
      74      201396 :                        equals("short-list"))
      75             :             {
      76           0 :                 return TYPE_SHORT_LIST;
      77      100698 :             } else if (xmlreader::Span(
      78      100698 :                            text.begin + i + 1, text.length - (i + 1)).
      79      201396 :                        equals("int-list"))
      80             :             {
      81        1143 :                 return TYPE_INT_LIST;
      82       98412 :             } else if (xmlreader::Span(
      83       98412 :                            text.begin + i + 1, text.length - (i + 1)).
      84      196824 :                        equals("long-list"))
      85             :             {
      86         381 :                 return TYPE_LONG_LIST;
      87       97650 :             } else if (xmlreader::Span(
      88       97650 :                            text.begin + i + 1, text.length - (i + 1)).
      89      195300 :                        equals("double-list"))
      90             :             {
      91           0 :                 return TYPE_DOUBLE_LIST;
      92       97650 :             } else if (xmlreader::Span(
      93       97650 :                            text.begin + i + 1, text.length - (i + 1)).
      94      195300 :                        equals("string-list"))
      95             :             {
      96       48825 :                 return TYPE_STRING_LIST;
      97           0 :             } else if (xmlreader::Span(
      98           0 :                            text.begin + i + 1, text.length - (i + 1)).
      99           0 :                        equals("hexBinary-list"))
     100             :             {
     101           0 :                 return TYPE_HEXBINARY_LIST;
     102             :             }
     103           0 :             break;
     104             :         case ParseManager::NAMESPACE_XS:
     105    13174208 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
     106    13174208 :                 equals("boolean"))
     107             :             {
     108      757811 :                 return TYPE_BOOLEAN;
     109     5071482 :             } else if (xmlreader::Span(
     110     5071482 :                            text.begin + i + 1, text.length - (i + 1)).
     111    10142964 :                        equals("short"))
     112             :             {
     113       42291 :                 return TYPE_SHORT;
     114     4986900 :             } else if (xmlreader::Span(
     115     4986900 :                            text.begin + i + 1, text.length - (i + 1)).
     116     9973800 :                        equals("int"))
     117             :             {
     118      687324 :                 return TYPE_INT;
     119     3612252 :             } else if (xmlreader::Span(
     120     3612252 :                            text.begin + i + 1, text.length - (i + 1)).
     121     7224504 :                        equals("long"))
     122             :             {
     123       10287 :                 return TYPE_LONG;
     124     3591678 :             } else if (xmlreader::Span(
     125     3591678 :                            text.begin + i + 1, text.length - (i + 1)).
     126     7183356 :                        equals("double"))
     127             :             {
     128       19050 :                 return TYPE_DOUBLE;
     129     3553578 :             } else if (xmlreader::Span(
     130     3553578 :                            text.begin + i + 1, text.length - (i + 1)).
     131     7107156 :                        equals("string"))
     132             :             {
     133     1774503 :                 return TYPE_STRING;
     134        4572 :             } else if (xmlreader::Span(
     135        4572 :                            text.begin + i + 1, text.length - (i + 1)).
     136        9144 :                        equals("hexBinary"))
     137             :             {
     138        2286 :                 return TYPE_HEXBINARY;
     139             :             }
     140           0 :             break;
     141             :         default:
     142           0 :             break;
     143             :         }
     144             :     }
     145             :     throw css::uno::RuntimeException(
     146           0 :         "invalid type " + text.convertFromUtf8());
     147             : }
     148             : 
     149      667800 : bool parseBoolean(xmlreader::Span const & text) {
     150             :     assert(text.is());
     151      667800 :     if (text.equals("true")) {
     152      145068 :         return true;
     153             :     }
     154      522732 :     if (text.equals("false")) {
     155      522732 :         return false;
     156             :     }
     157             :     throw css::uno::RuntimeException(
     158           0 :         "invalid boolean " + text.convertFromUtf8());
     159             : }
     160             : 
     161     2659329 : OUString parseTemplateReference(
     162             :     OUString const & component, bool hasNodeType,
     163             :     OUString const & nodeType, OUString const * defaultTemplateName)
     164             : {
     165     2659329 :     if (!hasNodeType) {
     166     2551887 :         if (defaultTemplateName != 0) {
     167     2551887 :             return *defaultTemplateName;
     168             :         }
     169             :         throw css::uno::RuntimeException(
     170           0 :             "missing node-type attribute");
     171             :     }
     172      107442 :     return Data::fullTemplateName(component, nodeType);
     173             : }
     174             : 
     175             : }
     176             : 
     177             : }
     178             : 
     179             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10