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/string.h"
33 #include "rtl/ustring.hxx"
34 #include "sal/types.h"
35 #include "xmlreader/span.hxx"
36 #include "xmlreader/xmlreader.hxx"
39 #include "groupnode.hxx"
40 #include "localizedpropertynode.hxx"
41 #include "localizedvaluenode.hxx"
43 #include "nodemap.hxx"
44 #include "parsemanager.hxx"
46 #include "propertynode.hxx"
47 #include "setnode.hxx"
55 xmlreader::XmlReader
const & reader
, xmlreader::Span
const & text
)
58 sal_Int32 i
= rtl_str_indexOfChar_WithLength(text
.begin
, text
.length
, ':');
60 switch (reader
.getNamespaceId(xmlreader::Span(text
.begin
, i
))) {
61 case ParseManager::NAMESPACE_OOR
:
62 if (xmlreader::Span(text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
66 } else if (xmlreader::Span(
67 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
68 equals("boolean-list"))
70 return TYPE_BOOLEAN_LIST
;
71 } else if (xmlreader::Span(
72 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
75 return TYPE_SHORT_LIST
;
76 } else if (xmlreader::Span(
77 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
81 } else if (xmlreader::Span(
82 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
85 return TYPE_LONG_LIST
;
86 } else if (xmlreader::Span(
87 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
88 equals("double-list"))
90 return TYPE_DOUBLE_LIST
;
91 } else if (xmlreader::Span(
92 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
93 equals("string-list"))
95 return TYPE_STRING_LIST
;
96 } else if (xmlreader::Span(
97 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
98 equals("hexBinary-list"))
100 return TYPE_HEXBINARY_LIST
;
103 case ParseManager::NAMESPACE_XS
:
104 if (xmlreader::Span(text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
108 } else if (xmlreader::Span(
109 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
113 } else if (xmlreader::Span(
114 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
118 } else if (xmlreader::Span(
119 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
123 } else if (xmlreader::Span(
124 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
128 } else if (xmlreader::Span(
129 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
133 } else if (xmlreader::Span(
134 text
.begin
+ i
+ 1, text
.length
- (i
+ 1)).
137 return TYPE_HEXBINARY
;
144 throw css::uno::RuntimeException(
145 "invalid type " + text
.convertFromUtf8(),
146 css::uno::Reference
< css::uno::XInterface
>());
149 bool parseBoolean(xmlreader::Span
const & text
) {
151 if (text
.equals("true")) {
154 if (text
.equals("false")) {
157 throw css::uno::RuntimeException(
158 "invalid boolean " + text
.convertFromUtf8(),
159 css::uno::Reference
< css::uno::XInterface
>());
162 OUString
parseTemplateReference(
163 OUString
const & component
, bool hasNodeType
,
164 OUString
const & nodeType
, OUString
const * defaultTemplateName
)
167 if (defaultTemplateName
!= 0) {
168 return *defaultTemplateName
;
170 throw css::uno::RuntimeException(
171 "missing node-type attribute",
172 css::uno::Reference
< css::uno::XInterface
>());
174 return Data::fullTemplateName(component
, nodeType
);
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */