LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/configmgr/source - xmldata.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 65 80 81.2 %
Date: 2013-07-09 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             : 
      50             : namespace configmgr {
      51             : 
      52             : namespace xmldata {
      53             : 
      54     1319454 : Type parseType(
      55             :     xmlreader::XmlReader const & reader, xmlreader::Span const & text)
      56             : {
      57             :     assert(text.is());
      58     1319454 :     sal_Int32 i = rtl_str_indexOfChar_WithLength(text.begin, text.length, ':');
      59     1319454 :     if (i >= 0) {
      60     1319454 :         switch (reader.getNamespaceId(xmlreader::Span(text.begin, i))) {
      61             :         case ParseManager::NAMESPACE_OOR:
      62       77672 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
      63       77672 :                 equals("any"))
      64             :             {
      65         459 :                 return TYPE_ANY;
      66       37918 :             } else if (xmlreader::Span(
      67       37918 :                            text.begin + i + 1, text.length - (i + 1)).
      68       75836 :                        equals("boolean-list"))
      69             :             {
      70           0 :                 return TYPE_BOOLEAN_LIST;
      71       37918 :             } else if (xmlreader::Span(
      72       37918 :                            text.begin + i + 1, text.length - (i + 1)).
      73       75836 :                        equals("short-list"))
      74             :             {
      75           0 :                 return TYPE_SHORT_LIST;
      76       37918 :             } else if (xmlreader::Span(
      77       37918 :                            text.begin + i + 1, text.length - (i + 1)).
      78       75836 :                        equals("int-list"))
      79             :             {
      80         459 :                 return TYPE_INT_LIST;
      81       37000 :             } else if (xmlreader::Span(
      82       37000 :                            text.begin + i + 1, text.length - (i + 1)).
      83       74000 :                        equals("long-list"))
      84             :             {
      85         153 :                 return TYPE_LONG_LIST;
      86       36694 :             } else if (xmlreader::Span(
      87       36694 :                            text.begin + i + 1, text.length - (i + 1)).
      88       73388 :                        equals("double-list"))
      89             :             {
      90           0 :                 return TYPE_DOUBLE_LIST;
      91       36694 :             } else if (xmlreader::Span(
      92       36694 :                            text.begin + i + 1, text.length - (i + 1)).
      93       73388 :                        equals("string-list"))
      94             :             {
      95       18347 :                 return TYPE_STRING_LIST;
      96           0 :             } else if (xmlreader::Span(
      97           0 :                            text.begin + i + 1, text.length - (i + 1)).
      98           0 :                        equals("hexBinary-list"))
      99             :             {
     100           0 :                 return TYPE_HEXBINARY_LIST;
     101             :             }
     102           0 :             break;
     103             :         case ParseManager::NAMESPACE_XS:
     104     5200144 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
     105     5200144 :                 equals("boolean"))
     106             :             {
     107      297924 :                 return TYPE_BOOLEAN;
     108     2004224 :             } else if (xmlreader::Span(
     109     2004224 :                            text.begin + i + 1, text.length - (i + 1)).
     110     4008448 :                        equals("short"))
     111             :             {
     112       16950 :                 return TYPE_SHORT;
     113     1970324 :             } else if (xmlreader::Span(
     114     1970324 :                            text.begin + i + 1, text.length - (i + 1)).
     115     3940648 :                        equals("int"))
     116             :             {
     117      268715 :                 return TYPE_INT;
     118     1432894 :             } else if (xmlreader::Span(
     119     1432894 :                            text.begin + i + 1, text.length - (i + 1)).
     120     2865788 :                        equals("long"))
     121             :             {
     122        4108 :                 return TYPE_LONG;
     123     1424678 :             } else if (xmlreader::Span(
     124     1424678 :                            text.begin + i + 1, text.length - (i + 1)).
     125     2849356 :                        equals("double"))
     126             :             {
     127        7650 :                 return TYPE_DOUBLE;
     128     1409378 :             } else if (xmlreader::Span(
     129     1409378 :                            text.begin + i + 1, text.length - (i + 1)).
     130     2818756 :                        equals("string"))
     131             :             {
     132      703771 :                 return TYPE_STRING;
     133        1836 :             } else if (xmlreader::Span(
     134        1836 :                            text.begin + i + 1, text.length - (i + 1)).
     135        3672 :                        equals("hexBinary"))
     136             :             {
     137         918 :                 return TYPE_HEXBINARY;
     138             :             }
     139           0 :             break;
     140             :         default:
     141           0 :             break;
     142             :         }
     143             :     }
     144             :     throw css::uno::RuntimeException(
     145           0 :         "invalid type " + text.convertFromUtf8(),
     146           0 :         css::uno::Reference< css::uno::XInterface >());
     147             : }
     148             : 
     149      260071 : bool parseBoolean(xmlreader::Span const & text) {
     150             :     assert(text.is());
     151      260071 :     if (text.equals("true")) {
     152       53674 :         return true;
     153             :     }
     154      206397 :     if (text.equals("false")) {
     155      206397 :         return false;
     156             :     }
     157             :     throw css::uno::RuntimeException(
     158           0 :         "invalid boolean " + text.convertFromUtf8(),
     159           0 :         css::uno::Reference< css::uno::XInterface >());
     160             : }
     161             : 
     162     1029253 : OUString parseTemplateReference(
     163             :     OUString const & component, bool hasNodeType,
     164             :     OUString const & nodeType, OUString const * defaultTemplateName)
     165             : {
     166     1029253 :     if (!hasNodeType) {
     167      986173 :         if (defaultTemplateName != 0) {
     168      986173 :             return *defaultTemplateName;
     169             :         }
     170             :         throw css::uno::RuntimeException(
     171             :             "missing node-type attribute",
     172           0 :             css::uno::Reference< css::uno::XInterface >());
     173             :     }
     174       43080 :     return Data::fullTemplateName(component, nodeType);
     175             : }
     176             : 
     177             : }
     178             : 
     179             : }
     180             : 
     181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10