1*2722ceddSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2722ceddSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2722ceddSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2722ceddSAndrew Rist * distributed with this work for additional information 6*2722ceddSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2722ceddSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2722ceddSAndrew Rist * "License"); you may not use this file except in compliance 9*2722ceddSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2722ceddSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2722ceddSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2722ceddSAndrew Rist * software distributed under the License is distributed on an 15*2722ceddSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2722ceddSAndrew Rist * KIND, either express or implied. See the License for the 17*2722ceddSAndrew Rist * specific language governing permissions and limitations 18*2722ceddSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2722ceddSAndrew Rist *************************************************************/ 21*2722ceddSAndrew Rist 22*2722ceddSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_desktop.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "dp_misc.h" 28cdf0e10cSrcweir #include "dp_xml.h" 29cdf0e10cSrcweir #include "rtl/ustrbuf.hxx" 30cdf0e10cSrcweir #include "ucbhelper/content.hxx" 31cdf0e10cSrcweir #include "com/sun/star/xml/sax/XParser.hpp" 32cdf0e10cSrcweir 33cdf0e10cSrcweir 34cdf0e10cSrcweir using namespace ::com::sun::star; 35cdf0e10cSrcweir using namespace ::com::sun::star::uno; 36cdf0e10cSrcweir using ::rtl::OUString; 37cdf0e10cSrcweir 38cdf0e10cSrcweir namespace dp_misc 39cdf0e10cSrcweir { 40cdf0e10cSrcweir 41cdf0e10cSrcweir //============================================================================== 42cdf0e10cSrcweir void xml_parse( 43cdf0e10cSrcweir Reference<xml::input::XRoot> const & xRoot, 44cdf0e10cSrcweir ::ucbhelper::Content & ucb_content, 45cdf0e10cSrcweir Reference<XComponentContext> const & xContext ) 46cdf0e10cSrcweir { 47cdf0e10cSrcweir const Any arg(xRoot); 48cdf0e10cSrcweir const Reference<xml::sax::XDocumentHandler> xDocHandler( 49cdf0e10cSrcweir xContext->getServiceManager()->createInstanceWithArgumentsAndContext( 50cdf0e10cSrcweir OUSTR("com.sun.star.xml.input.SaxDocumentHandler"), 51cdf0e10cSrcweir Sequence<Any>( &arg, 1 ), xContext ), UNO_QUERY_THROW ); 52cdf0e10cSrcweir xml_parse( xDocHandler, ucb_content, xContext ); 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55cdf0e10cSrcweir //============================================================================== 56cdf0e10cSrcweir void xml_parse( 57cdf0e10cSrcweir Reference<xml::sax::XDocumentHandler> const & xDocHandler, 58cdf0e10cSrcweir ::ucbhelper::Content & ucb_content, 59cdf0e10cSrcweir Reference<XComponentContext> const & xContext ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir // raise sax parser: 62cdf0e10cSrcweir Reference<xml::sax::XParser> xParser( 63cdf0e10cSrcweir xContext->getServiceManager()->createInstanceWithContext( 64cdf0e10cSrcweir OUSTR("com.sun.star.xml.sax.Parser"), xContext ), UNO_QUERY_THROW ); 65cdf0e10cSrcweir 66cdf0e10cSrcweir // error handler, entity resolver omitted 67cdf0e10cSrcweir xParser->setDocumentHandler( xDocHandler ); 68cdf0e10cSrcweir xml::sax::InputSource source; 69cdf0e10cSrcweir source.aInputStream = ucb_content.openStream(); 70cdf0e10cSrcweir source.sSystemId = ucb_content.getURL(); 71cdf0e10cSrcweir xParser->parseStream( source ); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir } 75