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>
25 #include <com/sun/star/container/NoSuchElementException.hpp>
26 #include <com/sun/star/uno/RuntimeException.hpp>
27 #include <sal/log.hxx>
28 #include <sal/types.h>
29 #include <xmlreader/span.hxx>
30 #include <xmlreader/xmlreader.hxx>
32 #include "parsemanager.hxx"
37 ParseManager::ParseManager(
38 OUString
const & url
, rtl::Reference
< Parser
> const & parser
)
39 : reader_(url
), parser_(parser
), itemNamespaceId_(-1)
43 id
= reader_
.registerNamespaceIri(
45 RTL_CONSTASCII_STRINGPARAM("http://openoffice.org/2001/registry")));
46 assert(id
== NAMESPACE_OOR
);
47 id
= reader_
.registerNamespaceIri(
49 RTL_CONSTASCII_STRINGPARAM("http://www.w3.org/2001/XMLSchema")));
50 assert(id
== NAMESPACE_XS
);
51 id
= reader_
.registerNamespaceIri(
53 RTL_CONSTASCII_STRINGPARAM(
54 "http://www.w3.org/2001/XMLSchema-instance")));
55 assert(id
== NAMESPACE_XSI
);
59 bool ParseManager::parse(std::set
< OUString
> const * existingDependencies
) {
60 sal_uInt32
startTime( osl_getGlobalTimer() );
62 switch (itemData_
.is()
63 ? xmlreader::XmlReader::Result::Begin
65 parser_
->getTextMode(), &itemData_
, &itemNamespaceId_
))
67 case xmlreader::XmlReader::Result::Begin
:
68 if (!parser_
->startElement(
69 reader_
, itemNamespaceId_
, itemData_
, existingDependencies
))
71 SAL_INFO("configmgr", "parsing " << reader_
.getUrl() << " took " << (osl_getGlobalTimer() - startTime
) << " ms, fail");
75 case xmlreader::XmlReader::Result::End
:
76 parser_
->endElement(reader_
);
78 case xmlreader::XmlReader::Result::Text
:
79 parser_
->characters(itemData_
);
81 case xmlreader::XmlReader::Result::Done
:
82 SAL_INFO("configmgr", "parsing " << reader_
.getUrl() << " took " << (osl_getGlobalTimer() - startTime
) << " ms, success");
89 ParseManager::~ParseManager() {}
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */