LCOV - code coverage report
Current view: top level - libreoffice/configmgr/source - xmldata.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 65 80 81.2 %
Date: 2012-12-27 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/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      263982 : Type parseType(
      58             :     xmlreader::XmlReader const & reader, xmlreader::Span const & text)
      59             : {
      60             :     assert(text.is());
      61      263982 :     sal_Int32 i = rtl_str_indexOfChar_WithLength(text.begin, text.length, ':');
      62      263982 :     if (i >= 0) {
      63      263982 :         switch (reader.getNamespaceId(xmlreader::Span(text.begin, i))) {
      64             :         case ParseManager::NAMESPACE_OOR:
      65       11082 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
      66       11082 :                 equals(RTL_CONSTASCII_STRINGPARAM("any")))
      67             :             {
      68          96 :                 return TYPE_ANY;
      69        7196 :             } else if (xmlreader::Span(
      70        3598 :                            text.begin + i + 1, text.length - (i + 1)).
      71       10794 :                        equals(RTL_CONSTASCII_STRINGPARAM("boolean-list")))
      72             :             {
      73           0 :                 return TYPE_BOOLEAN_LIST;
      74        7196 :             } else if (xmlreader::Span(
      75        3598 :                            text.begin + i + 1, text.length - (i + 1)).
      76       10794 :                        equals(RTL_CONSTASCII_STRINGPARAM("short-list")))
      77             :             {
      78           0 :                 return TYPE_SHORT_LIST;
      79        7196 :             } else if (xmlreader::Span(
      80        3598 :                            text.begin + i + 1, text.length - (i + 1)).
      81       10794 :                        equals(RTL_CONSTASCII_STRINGPARAM("int-list")))
      82             :             {
      83          96 :                 return TYPE_INT_LIST;
      84        7004 :             } else if (xmlreader::Span(
      85        3502 :                            text.begin + i + 1, text.length - (i + 1)).
      86       10506 :                        equals(RTL_CONSTASCII_STRINGPARAM("long-list")))
      87             :             {
      88          32 :                 return TYPE_LONG_LIST;
      89        6940 :             } else if (xmlreader::Span(
      90        3470 :                            text.begin + i + 1, text.length - (i + 1)).
      91       10410 :                        equals(RTL_CONSTASCII_STRINGPARAM("double-list")))
      92             :             {
      93           0 :                 return TYPE_DOUBLE_LIST;
      94        6940 :             } else if (xmlreader::Span(
      95        3470 :                            text.begin + i + 1, text.length - (i + 1)).
      96       10410 :                        equals(RTL_CONSTASCII_STRINGPARAM("string-list")))
      97             :             {
      98        3470 :                 return TYPE_STRING_LIST;
      99           0 :             } else if (xmlreader::Span(
     100           0 :                            text.begin + i + 1, text.length - (i + 1)).
     101           0 :                        equals(RTL_CONSTASCII_STRINGPARAM("hexBinary-list")))
     102             :             {
     103           0 :                 return TYPE_HEXBINARY_LIST;
     104             :             }
     105           0 :             break;
     106             :         case ParseManager::NAMESPACE_XS:
     107      780864 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
     108      780864 :                 equals(RTL_CONSTASCII_STRINGPARAM("boolean")))
     109             :             {
     110       60318 :                 return TYPE_BOOLEAN;
     111      399940 :             } else if (xmlreader::Span(
     112      199970 :                            text.begin + i + 1, text.length - (i + 1)).
     113      599910 :                        equals(RTL_CONSTASCII_STRINGPARAM("short")))
     114             :             {
     115        3616 :                 return TYPE_SHORT;
     116      392708 :             } else if (xmlreader::Span(
     117      196354 :                            text.begin + i + 1, text.length - (i + 1)).
     118      589062 :                        equals(RTL_CONSTASCII_STRINGPARAM("int")))
     119             :             {
     120       54350 :                 return TYPE_INT;
     121      284008 :             } else if (xmlreader::Span(
     122      142004 :                            text.begin + i + 1, text.length - (i + 1)).
     123      426012 :                        equals(RTL_CONSTASCII_STRINGPARAM("long")))
     124             :             {
     125         814 :                 return TYPE_LONG;
     126      282380 :             } else if (xmlreader::Span(
     127      141190 :                            text.begin + i + 1, text.length - (i + 1)).
     128      423570 :                        equals(RTL_CONSTASCII_STRINGPARAM("double")))
     129             :             {
     130        1600 :                 return TYPE_DOUBLE;
     131      279180 :             } else if (xmlreader::Span(
     132      139590 :                            text.begin + i + 1, text.length - (i + 1)).
     133      418770 :                        equals(RTL_CONSTASCII_STRINGPARAM("string")))
     134             :             {
     135      139398 :                 return TYPE_STRING;
     136         384 :             } else if (xmlreader::Span(
     137         192 :                            text.begin + i + 1, text.length - (i + 1)).
     138         576 :                        equals(RTL_CONSTASCII_STRINGPARAM("hexBinary")))
     139             :             {
     140         192 :                 return TYPE_HEXBINARY;
     141             :             }
     142           0 :             break;
     143             :         default:
     144           0 :             break;
     145             :         }
     146             :     }
     147             :     throw css::uno::RuntimeException(
     148             :         (OUString("invalid type ") +
     149           0 :          text.convertFromUtf8()),
     150           0 :         css::uno::Reference< css::uno::XInterface >());
     151             : }
     152             : 
     153      109474 : bool parseBoolean(xmlreader::Span const & text) {
     154             :     assert(text.is());
     155      109474 :     if (text.equals(RTL_CONSTASCII_STRINGPARAM("true"))) {
     156       65570 :         return true;
     157             :     }
     158       43904 :     if (text.equals(RTL_CONSTASCII_STRINGPARAM("false"))) {
     159       43904 :         return false;
     160             :     }
     161             :     throw css::uno::RuntimeException(
     162             :         (OUString("invalid boolean ") +
     163           0 :          text.convertFromUtf8()),
     164           0 :         css::uno::Reference< css::uno::XInterface >());
     165             : }
     166             : 
     167      251832 : OUString parseTemplateReference(
     168             :     OUString const & component, bool hasNodeType,
     169             :     OUString const & nodeType, OUString const * defaultTemplateName)
     170             : {
     171      251832 :     if (!hasNodeType) {
     172      242808 :         if (defaultTemplateName != 0) {
     173      242808 :             return *defaultTemplateName;
     174             :         }
     175             :         throw css::uno::RuntimeException(
     176             :             OUString("missing node-type attribute"),
     177           0 :             css::uno::Reference< css::uno::XInterface >());
     178             :     }
     179        9024 :     return Data::fullTemplateName(component, nodeType);
     180             : }
     181             : 
     182             : }
     183             : 
     184             : }
     185             : 
     186             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10