LCOV - code coverage report
Current view: top level - configmgr/source - xmldata.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 80 0.0 %
Date: 2014-04-14 Functions: 0 3 0.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           0 : Type parseType(
      56             :     xmlreader::XmlReader const & reader, xmlreader::Span const & text)
      57             : {
      58             :     assert(text.is());
      59           0 :     sal_Int32 i = rtl_str_indexOfChar_WithLength(text.begin, text.length, ':');
      60           0 :     if (i >= 0) {
      61           0 :         switch (reader.getNamespaceId(xmlreader::Span(text.begin, i))) {
      62             :         case ParseManager::NAMESPACE_OOR:
      63           0 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
      64           0 :                 equals("any"))
      65             :             {
      66           0 :                 return TYPE_ANY;
      67           0 :             } else if (xmlreader::Span(
      68           0 :                            text.begin + i + 1, text.length - (i + 1)).
      69           0 :                        equals("boolean-list"))
      70             :             {
      71           0 :                 return TYPE_BOOLEAN_LIST;
      72           0 :             } else if (xmlreader::Span(
      73           0 :                            text.begin + i + 1, text.length - (i + 1)).
      74           0 :                        equals("short-list"))
      75             :             {
      76           0 :                 return TYPE_SHORT_LIST;
      77           0 :             } else if (xmlreader::Span(
      78           0 :                            text.begin + i + 1, text.length - (i + 1)).
      79           0 :                        equals("int-list"))
      80             :             {
      81           0 :                 return TYPE_INT_LIST;
      82           0 :             } else if (xmlreader::Span(
      83           0 :                            text.begin + i + 1, text.length - (i + 1)).
      84           0 :                        equals("long-list"))
      85             :             {
      86           0 :                 return TYPE_LONG_LIST;
      87           0 :             } else if (xmlreader::Span(
      88           0 :                            text.begin + i + 1, text.length - (i + 1)).
      89           0 :                        equals("double-list"))
      90             :             {
      91           0 :                 return TYPE_DOUBLE_LIST;
      92           0 :             } else if (xmlreader::Span(
      93           0 :                            text.begin + i + 1, text.length - (i + 1)).
      94           0 :                        equals("string-list"))
      95             :             {
      96           0 :                 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           0 :             if (xmlreader::Span(text.begin + i + 1, text.length - (i + 1)).
     106           0 :                 equals("boolean"))
     107             :             {
     108           0 :                 return TYPE_BOOLEAN;
     109           0 :             } else if (xmlreader::Span(
     110           0 :                            text.begin + i + 1, text.length - (i + 1)).
     111           0 :                        equals("short"))
     112             :             {
     113           0 :                 return TYPE_SHORT;
     114           0 :             } else if (xmlreader::Span(
     115           0 :                            text.begin + i + 1, text.length - (i + 1)).
     116           0 :                        equals("int"))
     117             :             {
     118           0 :                 return TYPE_INT;
     119           0 :             } else if (xmlreader::Span(
     120           0 :                            text.begin + i + 1, text.length - (i + 1)).
     121           0 :                        equals("long"))
     122             :             {
     123           0 :                 return TYPE_LONG;
     124           0 :             } else if (xmlreader::Span(
     125           0 :                            text.begin + i + 1, text.length - (i + 1)).
     126           0 :                        equals("double"))
     127             :             {
     128           0 :                 return TYPE_DOUBLE;
     129           0 :             } else if (xmlreader::Span(
     130           0 :                            text.begin + i + 1, text.length - (i + 1)).
     131           0 :                        equals("string"))
     132             :             {
     133           0 :                 return TYPE_STRING;
     134           0 :             } else if (xmlreader::Span(
     135           0 :                            text.begin + i + 1, text.length - (i + 1)).
     136           0 :                        equals("hexBinary"))
     137             :             {
     138           0 :                 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           0 : bool parseBoolean(xmlreader::Span const & text) {
     151             :     assert(text.is());
     152           0 :     if (text.equals("true")) {
     153           0 :         return true;
     154             :     }
     155           0 :     if (text.equals("false")) {
     156           0 :         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           0 : OUString parseTemplateReference(
     164             :     OUString const & component, bool hasNodeType,
     165             :     OUString const & nodeType, OUString const * defaultTemplateName)
     166             : {
     167           0 :     if (!hasNodeType) {
     168           0 :         if (defaultTemplateName != 0) {
     169           0 :             return *defaultTemplateName;
     170             :         }
     171             :         throw css::uno::RuntimeException(
     172             :             "missing node-type attribute",
     173           0 :             css::uno::Reference< css::uno::XInterface >());
     174             :     }
     175           0 :     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