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>
26 #include <com/sun/star/uno/RuntimeException.hpp>
27 #include <com/sun/star/uno/XInterface.hpp>
28 #include <osl/file.hxx>
29 #include <rtl/ref.hxx>
30 #include <rtl/string.h>
31 #include <rtl/ustring.hxx>
32 #include <sal/types.h>
33 #include <xmlreader/span.hxx>
34 #include <xmlreader/xmlreader.hxx>
37 #include "groupnode.hxx"
38 #include "localizedpropertynode.hxx"
39 #include "localizedvaluenode.hxx"
41 #include "nodemap.hxx"
42 #include "parsemanager.hxx"
44 #include "propertynode.hxx"
45 #include "setnode.hxx"
47 #include "xmldata.hxx"
54 xmlreader::XmlReader
const & reader
, xmlreader::Span
const & text
)
57 sal_Int32 i
= rtl_str_indexOfChar_WithLength(text
.begin
, text
.length
, ':');
59 switch (reader
.getNamespaceId(xmlreader::Span(text
.begin
, i
))) {
60 case ParseManager::NAMESPACE_OOR
:
61 if (xmlreader::Span(text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
65 } else if (xmlreader::Span(
66 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
67 equals("boolean-list"))
69 return TYPE_BOOLEAN_LIST
;
70 } else if (xmlreader::Span(
71 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
74 return TYPE_SHORT_LIST
;
75 } else if (xmlreader::Span(
76 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
80 } else if (xmlreader::Span(
81 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
84 return TYPE_LONG_LIST
;
85 } else if (xmlreader::Span(
86 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
87 equals("double-list"))
89 return TYPE_DOUBLE_LIST
;
90 } else if (xmlreader::Span(
91 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
92 equals("string-list"))
94 return TYPE_STRING_LIST
;
95 } else if (xmlreader::Span(
96 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
97 equals("hexBinary-list"))
99 return TYPE_HEXBINARY_LIST
;
102 case ParseManager::NAMESPACE_XS
:
103 if (xmlreader::Span(text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
107 } else if (xmlreader::Span(
108 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
112 } else if (xmlreader::Span(
113 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
117 } else if (xmlreader::Span(
118 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
122 } else if (xmlreader::Span(
123 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
127 } else if (xmlreader::Span(
128 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
132 } else if (xmlreader::Span(
133 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
136 return TYPE_HEXBINARY
;
143 throw css::uno::RuntimeException(
144 "invalid type " + text
.convertFromUtf8());
147 bool parseBoolean(xmlreader::Span
const & text
) {
149 if (text
.equals("true")) {
152 if (text
.equals("false")) {
155 throw css::uno::RuntimeException(
156 "invalid boolean " + text
.convertFromUtf8());
159 OUString
parseTemplateReference(
160 OUString
const & component
, bool hasNodeType
,
161 OUString
const & nodeType
, OUString
const * defaultTemplateName
)
164 if (defaultTemplateName
!= nullptr) {
165 return *defaultTemplateName
;
167 throw css::uno::RuntimeException(
168 "missing node-type attribute");
170 return Data::fullTemplateName(component
, nodeType
);
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */