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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_desktop.hxx"
26
27 #include "dp_misc.h"
28 #include "dp_xml.h"
29 #include "rtl/ustrbuf.hxx"
30 #include "ucbhelper/content.hxx"
31 #include "com/sun/star/xml/sax/XParser.hpp"
32
33
34 using namespace ::com::sun::star;
35 using namespace ::com::sun::star::uno;
36 using ::rtl::OUString;
37
38 namespace dp_misc
39 {
40
41 //==============================================================================
xml_parse(Reference<xml::input::XRoot> const & xRoot,::ucbhelper::Content & ucb_content,Reference<XComponentContext> const & xContext)42 void xml_parse(
43 Reference<xml::input::XRoot> const & xRoot,
44 ::ucbhelper::Content & ucb_content,
45 Reference<XComponentContext> const & xContext )
46 {
47 const Any arg(xRoot);
48 const Reference<xml::sax::XDocumentHandler> xDocHandler(
49 xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
50 OUSTR("com.sun.star.xml.input.SaxDocumentHandler"),
51 Sequence<Any>( &arg, 1 ), xContext ), UNO_QUERY_THROW );
52 xml_parse( xDocHandler, ucb_content, xContext );
53 }
54
55 //==============================================================================
xml_parse(Reference<xml::sax::XDocumentHandler> const & xDocHandler,::ucbhelper::Content & ucb_content,Reference<XComponentContext> const & xContext)56 void xml_parse(
57 Reference<xml::sax::XDocumentHandler> const & xDocHandler,
58 ::ucbhelper::Content & ucb_content,
59 Reference<XComponentContext> const & xContext )
60 {
61 // raise sax parser:
62 Reference<xml::sax::XParser> xParser(
63 xContext->getServiceManager()->createInstanceWithContext(
64 OUSTR("com.sun.star.xml.sax.Parser"), xContext ), UNO_QUERY_THROW );
65
66 // error handler, entity resolver omitted
67 xParser->setDocumentHandler( xDocHandler );
68 xml::sax::InputSource source;
69 source.aInputStream = ucb_content.openStream();
70 source.sSystemId = ucb_content.getURL();
71 xParser->parseStream( source );
72 }
73
74 }
75