1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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>
32 #include "parsemanager.hxx"
34 #include "xmldata.hxx"
41 xmlreader::XmlReader
const & reader
, xmlreader::Span
const & text
)
44 sal_Int32 i
= rtl_str_indexOfChar_WithLength(text
.begin
, text
.length
, ':');
46 xmlreader::Span
token(text
.begin
+ i
+ 1, text
.length
- (i
+ 1));
47 switch (reader
.getNamespaceId(xmlreader::Span(text
.begin
, i
))) {
48 case ParseManager::NAMESPACE_OOR
:
52 } else if (token
== "boolean-list")
54 return TYPE_BOOLEAN_LIST
;
55 } else if (token
== "short-list")
57 return TYPE_SHORT_LIST
;
58 } else if (token
== "int-list")
61 } else if (token
== "long-list")
63 return TYPE_LONG_LIST
;
64 } else if (token
== "double-list")
66 return TYPE_DOUBLE_LIST
;
67 } else if (token
== "string-list")
69 return TYPE_STRING_LIST
;
70 } else if (token
== "hexBinary-list")
72 return TYPE_HEXBINARY_LIST
;
75 case ParseManager::NAMESPACE_XS
:
76 if (token
== "boolean")
79 } else if (token
=="short")
82 } else if (token
=="int")
85 } else if (token
=="long")
88 } else if (token
=="double")
91 } else if (token
=="string")
94 } else if (token
=="hexBinary")
96 return TYPE_HEXBINARY
;
103 throw css::uno::RuntimeException(
104 "invalid type " + text
.convertFromUtf8());
107 bool parseBoolean(xmlreader::Span
const & text
) {
109 if (text
== "true") {
112 if (text
== "false") {
115 throw css::uno::RuntimeException(
116 "invalid boolean " + text
.convertFromUtf8());
119 OUString
parseTemplateReference(
120 OUString
const & component
, bool hasNodeType
,
121 OUString
const & nodeType
, OUString
const * defaultTemplateName
)
124 if (defaultTemplateName
!= nullptr) {
125 return *defaultTemplateName
;
127 throw css::uno::RuntimeException(
128 "missing node-type attribute");
130 return Data::fullTemplateName(component
, nodeType
);
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */