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/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"
42 #include "groupnode.hxx"
43 #include "localizedpropertynode.hxx"
44 #include "localizedvaluenode.hxx"
46 #include "nodemap.hxx"
47 #include "parsemanager.hxx"
49 #include "propertynode.hxx"
50 #include "setnode.hxx"
58 xmlreader::XmlReader
const & reader
, xmlreader::Span
const & text
)
61 sal_Int32 i
= rtl_str_indexOfChar_WithLength(text
.begin
, text
.length
, ':');
63 switch (reader
.getNamespaceId(xmlreader::Span(text
.begin
, i
))) {
64 case ParseManager::NAMESPACE_OOR
:
65 if (xmlreader::Span(text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
66 equals(RTL_CONSTASCII_STRINGPARAM("any")))
69 } else if (xmlreader::Span(
70 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
71 equals(RTL_CONSTASCII_STRINGPARAM("boolean-list")))
73 return TYPE_BOOLEAN_LIST
;
74 } else if (xmlreader::Span(
75 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
76 equals(RTL_CONSTASCII_STRINGPARAM("short-list")))
78 return TYPE_SHORT_LIST
;
79 } else if (xmlreader::Span(
80 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
81 equals(RTL_CONSTASCII_STRINGPARAM("int-list")))
84 } else if (xmlreader::Span(
85 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
86 equals(RTL_CONSTASCII_STRINGPARAM("long-list")))
88 return TYPE_LONG_LIST
;
89 } else if (xmlreader::Span(
90 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
91 equals(RTL_CONSTASCII_STRINGPARAM("double-list")))
93 return TYPE_DOUBLE_LIST
;
94 } else if (xmlreader::Span(
95 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
96 equals(RTL_CONSTASCII_STRINGPARAM("string-list")))
98 return TYPE_STRING_LIST
;
99 } else if (xmlreader::Span(
100 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
101 equals(RTL_CONSTASCII_STRINGPARAM("hexBinary-list")))
103 return TYPE_HEXBINARY_LIST
;
106 case ParseManager::NAMESPACE_XS
:
107 if (xmlreader::Span(text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
108 equals(RTL_CONSTASCII_STRINGPARAM("boolean")))
111 } else if (xmlreader::Span(
112 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
113 equals(RTL_CONSTASCII_STRINGPARAM("short")))
116 } else if (xmlreader::Span(
117 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
118 equals(RTL_CONSTASCII_STRINGPARAM("int")))
121 } else if (xmlreader::Span(
122 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
123 equals(RTL_CONSTASCII_STRINGPARAM("long")))
126 } else if (xmlreader::Span(
127 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
128 equals(RTL_CONSTASCII_STRINGPARAM("double")))
131 } else if (xmlreader::Span(
132 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
133 equals(RTL_CONSTASCII_STRINGPARAM("string")))
136 } else if (xmlreader::Span(
137 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
138 equals(RTL_CONSTASCII_STRINGPARAM("hexBinary")))
140 return TYPE_HEXBINARY
;
147 throw css::uno::RuntimeException(
148 (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("invalid type ")) +
149 text
.convertFromUtf8()),
150 css::uno::Reference
< css::uno::XInterface
>());
153 bool parseBoolean(xmlreader::Span
const & text
) {
155 if (text
.equals(RTL_CONSTASCII_STRINGPARAM("true"))) {
158 if (text
.equals(RTL_CONSTASCII_STRINGPARAM("false"))) {
161 throw css::uno::RuntimeException(
162 (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("invalid boolean ")) +
163 text
.convertFromUtf8()),
164 css::uno::Reference
< css::uno::XInterface
>());
167 rtl::OUString
parseTemplateReference(
168 rtl::OUString
const & component
, bool hasNodeType
,
169 rtl::OUString
const & nodeType
, rtl::OUString
const * defaultTemplateName
)
172 if (defaultTemplateName
!= 0) {
173 return *defaultTemplateName
;
175 throw css::uno::RuntimeException(
177 RTL_CONSTASCII_USTRINGPARAM("missing node-type attribute")),
178 css::uno::Reference
< css::uno::XInterface
>());
180 return Data::fullTemplateName(component
, nodeType
);
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */