1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include "precompiled_configmgr.hxx"
25 #include "sal/config.h"
26
27 #include "com/sun/star/container/NoSuchElementException.hpp"
28 #include "com/sun/star/uno/RuntimeException.hpp"
29 #include "osl/diagnose.h"
30 #include "sal/types.h"
31 #include "xmlreader/span.hxx"
32 #include "xmlreader/xmlreader.hxx"
33
34 #include "parsemanager.hxx"
35 #include "parser.hxx"
36
37 namespace configmgr {
38
39 namespace {
40
41 namespace css = com::sun::star;
42
43 }
44
ParseManager(rtl::OUString const & url,rtl::Reference<Parser> const & parser)45 ParseManager::ParseManager(
46 rtl::OUString const & url, rtl::Reference< Parser > const & parser):
47 reader_(url), parser_(parser)
48 {
49 OSL_ASSERT(parser.is());
50 int id;
51 id = reader_.registerNamespaceIri(
52 xmlreader::Span(
53 RTL_CONSTASCII_STRINGPARAM("http://openoffice.org/2001/registry")));
54 OSL_ASSERT(id == NAMESPACE_OOR);
55 id = reader_.registerNamespaceIri(
56 xmlreader::Span(
57 RTL_CONSTASCII_STRINGPARAM("http://www.w3.org/2001/XMLSchema")));
58 OSL_ASSERT(id == NAMESPACE_XS);
59 id = reader_.registerNamespaceIri(
60 xmlreader::Span(
61 RTL_CONSTASCII_STRINGPARAM(
62 "http://www.w3.org/2001/XMLSchema-instance")));
63 OSL_ASSERT(id == NAMESPACE_XSI);
64 }
65
parse()66 bool ParseManager::parse() {
67 for (;;) {
68 switch (itemData_.is()
69 ? xmlreader::XmlReader::RESULT_BEGIN
70 : reader_.nextItem(
71 parser_->getTextMode(), &itemData_, &itemNamespaceId_))
72 {
73 case xmlreader::XmlReader::RESULT_BEGIN:
74 if (!parser_->startElement(reader_, itemNamespaceId_, itemData_))
75 {
76 return false;
77 }
78 break;
79 case xmlreader::XmlReader::RESULT_END:
80 parser_->endElement(reader_);
81 break;
82 case xmlreader::XmlReader::RESULT_TEXT:
83 parser_->characters(itemData_);
84 break;
85 case xmlreader::XmlReader::RESULT_DONE:
86 return true;
87 }
88 itemData_.clear();
89 }
90 }
91
~ParseManager()92 ParseManager::~ParseManager() {}
93
94 }
95