tdf#154546 skip dispatch when presenter controller is not set
[LibreOffice.git] / configmgr / source / xmldata.cxx
blobecb4dacab41f2ee7e510168fc8ce3251fd4ff6f3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <cassert>
24 #include <com/sun/star/uno/RuntimeException.hpp>
25 #include <rtl/string.h>
26 #include <rtl/ustring.hxx>
27 #include <sal/types.h>
28 #include <xmlreader/span.hxx>
29 #include <xmlreader/xmlreader.hxx>
31 #include "data.hxx"
32 #include "parsemanager.hxx"
33 #include "type.hxx"
34 #include "xmldata.hxx"
36 namespace configmgr::xmldata {
38 Type parseType(
39 xmlreader::XmlReader const & reader, xmlreader::Span const & text)
41 assert(text.is());
42 sal_Int32 i = rtl_str_indexOfChar_WithLength(text.begin, text.length, ':');
43 if (i >= 0) {
44 xmlreader::Span token(text.begin + i + 1, text.length - (i + 1));
45 switch (reader.getNamespaceId(xmlreader::Span(text.begin, i))) {
46 case ParseManager::NAMESPACE_OOR:
47 if (token == "any")
49 return TYPE_ANY;
50 } else if (token == "boolean-list")
52 return TYPE_BOOLEAN_LIST;
53 } else if (token == "short-list")
55 return TYPE_SHORT_LIST;
56 } else if (token == "int-list")
58 return TYPE_INT_LIST;
59 } else if (token == "long-list")
61 return TYPE_LONG_LIST;
62 } else if (token == "double-list")
64 return TYPE_DOUBLE_LIST;
65 } else if (token == "string-list")
67 return TYPE_STRING_LIST;
68 } else if (token == "hexBinary-list")
70 return TYPE_HEXBINARY_LIST;
72 break;
73 case ParseManager::NAMESPACE_XS:
74 if (token == "boolean")
76 return TYPE_BOOLEAN;
77 } else if (token =="short")
79 return TYPE_SHORT;
80 } else if (token =="int")
82 return TYPE_INT;
83 } else if (token =="long")
85 return TYPE_LONG;
86 } else if (token =="double")
88 return TYPE_DOUBLE;
89 } else if (token =="string")
91 return TYPE_STRING;
92 } else if (token =="hexBinary")
94 return TYPE_HEXBINARY;
96 break;
97 default:
98 break;
101 throw css::uno::RuntimeException(
102 "invalid type " + text.convertFromUtf8());
105 bool parseBoolean(xmlreader::Span const & text) {
106 assert(text.is());
107 if (text == "true") {
108 return true;
110 if (text == "false") {
111 return false;
113 throw css::uno::RuntimeException(
114 "invalid boolean " + text.convertFromUtf8());
117 OUString parseTemplateReference(
118 std::u16string_view component, bool hasNodeType,
119 std::u16string_view nodeType, OUString const * defaultTemplateName)
121 if (!hasNodeType) {
122 if (defaultTemplateName != nullptr) {
123 return *defaultTemplateName;
125 throw css::uno::RuntimeException(
126 "missing node-type attribute");
128 return Data::fullTemplateName(component, nodeType);
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */