LCOV - code coverage report
Current view: top level - configmgr/source - xmldata.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 65 80 81.2 %
Date: 2014-04-11 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     1472962 : Type parseType(
      56             :     xmlreader::XmlReader const & reader, xmlreader::Span const & text)
      57             : {
      58             :     assert(text.is());
      59     1472962 :     sal_Int32 i = rtl_str_indexOfChar_WithLength(text.begin, text.length, ':');
      60     1472962 :     if (i >= 0) {
      61     1472962 :         switch (reader.getNamespaceId(xmlreader::Span(text.begin, i))) {
      62             :         case ParseManager::NAMESPACE_OOR:
      63       89472 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
      64       89472 :                 equals("any"))
      65             :             {
      66         504 :                 return TYPE_ANY;
      67       43728 :             } else if (xmlreader::Span(
      68       43728 :                            text.begin + i + 1, text.length - (i + 1)).
      69       87456 :                        equals("boolean-list"))
      70             :             {
      71           0 :                 return TYPE_BOOLEAN_LIST;
      72       43728 :             } else if (xmlreader::Span(
      73       43728 :                            text.begin + i + 1, text.length - (i + 1)).
      74       87456 :                        equals("short-list"))
      75             :             {
      76           0 :                 return TYPE_SHORT_LIST;
      77       43728 :             } else if (xmlreader::Span(
      78       43728 :                            text.begin + i + 1, text.length - (i + 1)).
      79       87456 :                        equals("int-list"))
      80             :             {
      81         504 :                 return TYPE_INT_LIST;
      82       42720 :             } else if (xmlreader::Span(
      83       42720 :                            text.begin + i + 1, text.length - (i + 1)).
      84       85440 :                        equals("long-list"))
      85             :             {
      86         168 :                 return TYPE_LONG_LIST;
      87       42384 :             } else if (xmlreader::Span(
      88       42384 :                            text.begin + i + 1, text.length - (i + 1)).
      89       84768 :                        equals("double-list"))
      90             :             {
      91           0 :                 return TYPE_DOUBLE_LIST;
      92       42384 :             } else if (xmlreader::Span(
      93       42384 :                            text.begin + i + 1, text.length - (i + 1)).
      94       84768 :                        equals("string-list"))
      95             :             {
      96       21192 :                 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     5802376 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
     106     5802376 :                 equals("boolean"))
     107             :             {
     108      334656 :                 return TYPE_BOOLEAN;
     109     2231876 :             } else if (xmlreader::Span(
     110     2231876 :                            text.begin + i + 1, text.length - (i + 1)).
     111     4463752 :                        equals("short"))
     112             :             {
     113       18648 :                 return TYPE_SHORT;
     114     2194580 :             } else if (xmlreader::Span(
     115     2194580 :                            text.begin + i + 1, text.length - (i + 1)).
     116     4389160 :                        equals("int"))
     117             :             {
     118      300720 :                 return TYPE_INT;
     119     1593140 :             } else if (xmlreader::Span(
     120     1593140 :                            text.begin + i + 1, text.length - (i + 1)).
     121     3186280 :                        equals("long"))
     122             :             {
     123        4536 :                 return TYPE_LONG;
     124     1584068 :             } else if (xmlreader::Span(
     125     1584068 :                            text.begin + i + 1, text.length - (i + 1)).
     126     3168136 :                        equals("double"))
     127             :             {
     128        8400 :                 return TYPE_DOUBLE;
     129     1567268 :             } else if (xmlreader::Span(
     130     1567268 :                            text.begin + i + 1, text.length - (i + 1)).
     131     3134536 :                        equals("string"))
     132             :             {
     133      782626 :                 return TYPE_STRING;
     134        2016 :             } else if (xmlreader::Span(
     135        2016 :                            text.begin + i + 1, text.length - (i + 1)).
     136        4032 :                        equals("hexBinary"))
     137             :             {
     138        1008 :                 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           0 :         css::uno::Reference< css::uno::XInterface >());
     148             : }
     149             : 
     150      292143 : bool parseBoolean(xmlreader::Span const & text) {
     151             :     assert(text.is());
     152      292143 :     if (text.equals("true")) {
     153       63663 :         return true;
     154             :     }
     155      228480 :     if (text.equals("false")) {
     156      228480 :         return false;
     157             :     }
     158             :     throw css::uno::RuntimeException(
     159           0 :         "invalid boolean " + text.convertFromUtf8(),
     160           0 :         css::uno::Reference< css::uno::XInterface >());
     161             : }
     162             : 
     163     1164381 : OUString parseTemplateReference(
     164             :     OUString const & component, bool hasNodeType,
     165             :     OUString const & nodeType, OUString const * defaultTemplateName)
     166             : {
     167     1164381 :     if (!hasNodeType) {
     168     1117173 :         if (defaultTemplateName != 0) {
     169     1117173 :             return *defaultTemplateName;
     170             :         }
     171             :         throw css::uno::RuntimeException(
     172             :             "missing node-type attribute",
     173           0 :             css::uno::Reference< css::uno::XInterface >());
     174             :     }
     175       47208 :     return Data::fullTemplateName(component, nodeType);
     176             : }
     177             : 
     178             : }
     179             : 
     180             : }
     181             : 
     182             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10