Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "sal/config.h"
21 :
22 : #include <cassert>
23 : #include <set>
24 :
25 : #include "com/sun/star/container/NoSuchElementException.hpp"
26 : #include "com/sun/star/uno/RuntimeException.hpp"
27 : #include "sal/types.h"
28 : #include "xmlreader/span.hxx"
29 : #include "xmlreader/xmlreader.hxx"
30 :
31 : #include "parsemanager.hxx"
32 : #include "parser.hxx"
33 :
34 : namespace configmgr {
35 :
36 19399 : ParseManager::ParseManager(
37 : OUString const & url, rtl::Reference< Parser > const & parser)
38 : SAL_THROW((
39 : css::container::NoSuchElementException, css::uno::RuntimeException)):
40 19399 : reader_(url), parser_(parser)
41 : {
42 : assert(parser.is());
43 : int id;
44 : id = reader_.registerNamespaceIri(
45 : xmlreader::Span(
46 19366 : RTL_CONSTASCII_STRINGPARAM("http://openoffice.org/2001/registry")));
47 : assert(id == NAMESPACE_OOR);
48 : id = reader_.registerNamespaceIri(
49 : xmlreader::Span(
50 19366 : RTL_CONSTASCII_STRINGPARAM("http://www.w3.org/2001/XMLSchema")));
51 : assert(id == NAMESPACE_XS);
52 : id = reader_.registerNamespaceIri(
53 : xmlreader::Span(
54 : RTL_CONSTASCII_STRINGPARAM(
55 19366 : "http://www.w3.org/2001/XMLSchema-instance")));
56 : assert(id == NAMESPACE_XSI);
57 : (void)id;
58 19366 : }
59 :
60 37245024 : bool ParseManager::parse(std::set< OUString > const * existingDependencies) {
61 : for (;;) {
62 37264390 : switch (itemData_.is()
63 : ? xmlreader::XmlReader::RESULT_BEGIN
64 : : reader_.nextItem(
65 18632110 : parser_->getTextMode(), &itemData_, &itemNamespaceId_))
66 : {
67 : case xmlreader::XmlReader::RESULT_BEGIN:
68 15968814 : if (!parser_->startElement(
69 7984407 : reader_, itemNamespaceId_, itemData_, existingDependencies))
70 : {
71 170 : return false;
72 : }
73 7984237 : break;
74 : case xmlreader::XmlReader::RESULT_END:
75 7984237 : parser_->endElement(reader_);
76 7984237 : break;
77 : case xmlreader::XmlReader::RESULT_TEXT:
78 2644270 : parser_->characters(itemData_);
79 2644270 : break;
80 : case xmlreader::XmlReader::RESULT_DONE:
81 19366 : return true;
82 : }
83 18612744 : itemData_.clear();
84 : }
85 : }
86 :
87 38732 : ParseManager::~ParseManager() {}
88 :
89 : }
90 :
91 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|